
_roses:     file format elf32-i386


Disassembly of section .text:

00000000 <charCat>:
	}
}


void
charCat(char* str, char c) {
       0:	55                   	push   %ebp
       1:	89 e5                	mov    %esp,%ebp
	char* point = str;
	while((*point) != '\0') {
       3:	8b 45 08             	mov    0x8(%ebp),%eax
	}
}


void
charCat(char* str, char c) {
       6:	0f b6 55 0c          	movzbl 0xc(%ebp),%edx
	char* point = str;
	while((*point) != '\0') {
       a:	80 38 00             	cmpb   $0x0,(%eax)
       d:	74 09                	je     18 <charCat+0x18>
       f:	90                   	nop
		point++;
      10:	83 c0 01             	add    $0x1,%eax


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
      13:	80 38 00             	cmpb   $0x0,(%eax)
      16:	75 f8                	jne    10 <charCat+0x10>
		point++;
	}
	(*point) = c;
      18:	88 10                	mov    %dl,(%eax)
	point++;
	(*point) = '\0';
      1a:	c6 40 01 00          	movb   $0x0,0x1(%eax)
}
      1e:	5d                   	pop    %ebp
      1f:	c3                   	ret    

00000020 <addNewRequest>:
		return -1;
	}
	return 0;
}

void addNewRequest( Request* newReq) {
      20:	55                   	push   %ebp
      21:	89 e5                	mov    %esp,%ebp
      23:	83 ec 18             	sub    $0x18,%esp
	semaphore_put(RBB,(void*)newReq);
      26:	8b 45 08             	mov    0x8(%ebp),%eax
      29:	89 44 24 04          	mov    %eax,0x4(%esp)
      2d:	a1 7c 17 00 00       	mov    0x177c,%eax
      32:	89 04 24             	mov    %eax,(%esp)
      35:	e8 f6 13 00 00       	call   1430 <semaphore_put>
}
      3a:	c9                   	leave  
      3b:	c3                   	ret    
      3c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00000040 <readFromFile>:
	(*point) = '\0';
}

void
readFromFile()
{
      40:	55                   	push   %ebp
      41:	89 e5                	mov    %esp,%ebp
      43:	57                   	push   %edi
      44:	56                   	push   %esi
      45:	53                   	push   %ebx
      46:	83 ec 7c             	sub    $0x7c,%esp
	int counter = 0;
	int flag = 0;
	char Bstr[11] = "\0";
      49:	0f b7 05 9d 15 00 00 	movzwl 0x159d,%eax
      50:	c7 45 de 00 00 00 00 	movl   $0x0,-0x22(%ebp)
      57:	c7 45 e2 00 00 00 00 	movl   $0x0,-0x1e(%ebp)
      5e:	c6 45 e6 00          	movb   $0x0,-0x1a(%ebp)
      62:	66 89 45 dc          	mov    %ax,-0x24(%ebp)
	char Hstr[11] = "\0";;
      66:	66 89 45 d1          	mov    %ax,-0x2f(%ebp)
      6a:	c7 45 d3 00 00 00 00 	movl   $0x0,-0x2d(%ebp)
      71:	c7 45 d7 00 00 00 00 	movl   $0x0,-0x29(%ebp)
      78:	c6 45 db 00          	movb   $0x0,-0x25(%ebp)
	char Rstr[11] = "\0";;
      7c:	66 89 45 c6          	mov    %ax,-0x3a(%ebp)
      80:	c7 45 c8 00 00 00 00 	movl   $0x0,-0x38(%ebp)
      87:	c7 45 cc 00 00 00 00 	movl   $0x0,-0x34(%ebp)
      8e:	c6 45 d0 00          	movb   $0x0,-0x30(%ebp)
	char Cstr[11] = "\0";;
      92:	66 89 45 bb          	mov    %ax,-0x45(%ebp)
      96:	c7 45 bd 00 00 00 00 	movl   $0x0,-0x43(%ebp)
      9d:	c7 45 c1 00 00 00 00 	movl   $0x0,-0x3f(%ebp)
      a4:	c6 45 c5 00          	movb   $0x0,-0x3b(%ebp)
	char totalRequestsstr[11];
	int fd = open("con.conf",O_RDONLY);
      a8:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
      af:	00 
      b0:	c7 04 24 50 15 00 00 	movl   $0x1550,(%esp)
      b7:	e8 6c 0b 00 00       	call   c28 <open>
	if(fd < 0) {
      bc:	85 c0                	test   %eax,%eax
	char Bstr[11] = "\0";
	char Hstr[11] = "\0";;
	char Rstr[11] = "\0";;
	char Cstr[11] = "\0";;
	char totalRequestsstr[11];
	int fd = open("con.conf",O_RDONLY);
      be:	89 c6                	mov    %eax,%esi
	if(fd < 0) {
      c0:	0f 88 05 02 00 00    	js     2cb <readFromFile+0x28b>
      c6:	c7 45 94 00 00 00 00 	movl   $0x0,-0x6c(%ebp)
      cd:	8d 7d e7             	lea    -0x19(%ebp),%edi
		printf(2,"problem opening file");
		exit();
	}
	char readbuf;
	while(read(fd,&readbuf,1) > 0)
      d0:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
      d7:	00 
      d8:	89 7c 24 04          	mov    %edi,0x4(%esp)
      dc:	89 34 24             	mov    %esi,(%esp)
      df:	e8 1c 0b 00 00       	call   c00 <read>
      e4:	85 c0                	test   %eax,%eax
      e6:	0f 8e bc 00 00 00    	jle    1a8 <readFromFile+0x168>
	{
		if(readbuf == 'B') {
      ec:	0f b6 55 e7          	movzbl -0x19(%ebp),%edx
      f0:	80 fa 42             	cmp    $0x42,%dl
      f3:	0f 84 af 01 00 00    	je     2a8 <readFromFile+0x268>
			flag = 1;
			counter++;
		}
		if(readbuf == 'H') {
      f9:	80 fa 48             	cmp    $0x48,%dl
      fc:	0f 84 96 01 00 00    	je     298 <readFromFile+0x258>
			flag = 2;
			counter++;
		}
		if(readbuf == 'R') {
     102:	80 fa 52             	cmp    $0x52,%dl
     105:	0f 85 ad 01 00 00    	jne    2b8 <readFromFile+0x278>
			flag = 3;
			counter++;
     10b:	83 45 94 01          	addl   $0x1,-0x6c(%ebp)
     10f:	bb 03 00 00 00       	mov    $0x3,%ebx
     114:	eb 06                	jmp    11c <readFromFile+0xdc>
     116:	66 90                	xchg   %ax,%ax
				counter++;
			}
		}
		if(flag > 0) { //if one of the conditions above apply, we need to extract the number
			while((readbuf < '0') || (readbuf > '9')) { //read untill we reach a number
				if(read(fd,&readbuf,1) <= 0)
     118:	0f b6 55 e7          	movzbl -0x19(%ebp),%edx
				flag = 5;
				counter++;
			}
		}
		if(flag > 0) { //if one of the conditions above apply, we need to extract the number
			while((readbuf < '0') || (readbuf > '9')) { //read untill we reach a number
     11c:	8d 42 d0             	lea    -0x30(%edx),%eax
     11f:	3c 09                	cmp    $0x9,%al
     121:	76 21                	jbe    144 <readFromFile+0x104>
				if(read(fd,&readbuf,1) <= 0)
     123:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     12a:	00 
     12b:	89 7c 24 04          	mov    %edi,0x4(%esp)
     12f:	89 34 24             	mov    %esi,(%esp)
     132:	e8 c9 0a 00 00       	call   c00 <read>
     137:	85 c0                	test   %eax,%eax
     139:	7f dd                	jg     118 <readFromFile+0xd8>
     13b:	90                   	nop
     13c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
				if(flag == 4)
					charCat(Cstr,readbuf);
				if(flag == 5)
					charCat(totalRequestsstr,readbuf);

				if(read(fd,&readbuf,1) <= 0)
     140:	0f b6 55 e7          	movzbl -0x19(%ebp),%edx
		if(flag > 0) { //if one of the conditions above apply, we need to extract the number
			while((readbuf < '0') || (readbuf > '9')) { //read untill we reach a number
				if(read(fd,&readbuf,1) <= 0)
					break;
			}
			while((readbuf >= '0') && (readbuf <= '9')) { //when we reach an number, we read it and concat it to a string
     144:	8d 42 d0             	lea    -0x30(%edx),%eax
     147:	3c 09                	cmp    $0x9,%al
     149:	77 53                	ja     19e <readFromFile+0x15e>
				if(flag == 1)
     14b:	83 fb 01             	cmp    $0x1,%ebx
     14e:	0f 84 d4 00 00 00    	je     228 <readFromFile+0x1e8>
					charCat(Bstr,readbuf);
				if(flag == 2)
     154:	83 fb 02             	cmp    $0x2,%ebx
     157:	0f 84 ab 00 00 00    	je     208 <readFromFile+0x1c8>
					charCat(Hstr,readbuf);
				if(flag == 3)
     15d:	83 fb 03             	cmp    $0x3,%ebx
     160:	0f 85 e2 00 00 00    	jne    248 <readFromFile+0x208>


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     166:	80 7d c6 00          	cmpb   $0x0,-0x3a(%ebp)
     16a:	8d 45 c6             	lea    -0x3a(%ebp),%eax
     16d:	8d 76 00             	lea    0x0(%esi),%esi
     170:	74 0e                	je     180 <readFromFile+0x140>
     172:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
		point++;
     178:	83 c0 01             	add    $0x1,%eax


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     17b:	80 38 00             	cmpb   $0x0,(%eax)
     17e:	75 f8                	jne    178 <readFromFile+0x138>
		point++;
	}
	(*point) = c;
     180:	88 10                	mov    %dl,(%eax)
	point++;
	(*point) = '\0';
     182:	c6 40 01 00          	movb   $0x0,0x1(%eax)
				if(flag == 4)
					charCat(Cstr,readbuf);
				if(flag == 5)
					charCat(totalRequestsstr,readbuf);

				if(read(fd,&readbuf,1) <= 0)
     186:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     18d:	00 
     18e:	89 7c 24 04          	mov    %edi,0x4(%esp)
     192:	89 34 24             	mov    %esi,(%esp)
     195:	e8 66 0a 00 00       	call   c00 <read>
     19a:	85 c0                	test   %eax,%eax
     19c:	7f a2                	jg     140 <readFromFile+0x100>
					break;
			}
			flag = 0;
		}
		if(counter >=5) {//if we read all 5 numbers we stop
     19e:	83 7d 94 04          	cmpl   $0x4,-0x6c(%ebp)
     1a2:	0f 8e 28 ff ff ff    	jle    d0 <readFromFile+0x90>
			break;
		}
	}
	B = atoi(Bstr);
     1a8:	8d 45 dc             	lea    -0x24(%ebp),%eax
     1ab:	89 04 24             	mov    %eax,(%esp)
     1ae:	e8 0d 09 00 00       	call   ac0 <atoi>
     1b3:	a3 94 17 00 00       	mov    %eax,0x1794
	H = atoi(Hstr);
     1b8:	8d 45 d1             	lea    -0x2f(%ebp),%eax
     1bb:	89 04 24             	mov    %eax,(%esp)
     1be:	e8 fd 08 00 00       	call   ac0 <atoi>
     1c3:	a3 a0 17 00 00       	mov    %eax,0x17a0
	R = atoi(Rstr);
     1c8:	8d 45 c6             	lea    -0x3a(%ebp),%eax
     1cb:	89 04 24             	mov    %eax,(%esp)
     1ce:	e8 ed 08 00 00       	call   ac0 <atoi>
     1d3:	a3 a4 17 00 00       	mov    %eax,0x17a4
	C = atoi(Cstr);
     1d8:	8d 45 bb             	lea    -0x45(%ebp),%eax
     1db:	89 04 24             	mov    %eax,(%esp)
     1de:	e8 dd 08 00 00       	call   ac0 <atoi>
     1e3:	a3 9c 17 00 00       	mov    %eax,0x179c
	totalRequests = atoi(totalRequestsstr);
     1e8:	8d 45 b0             	lea    -0x50(%ebp),%eax
     1eb:	89 04 24             	mov    %eax,(%esp)
     1ee:	e8 cd 08 00 00       	call   ac0 <atoi>
	close(fd);
     1f3:	89 34 24             	mov    %esi,(%esp)
	}
	B = atoi(Bstr);
	H = atoi(Hstr);
	R = atoi(Rstr);
	C = atoi(Cstr);
	totalRequests = atoi(totalRequestsstr);
     1f6:	a3 78 17 00 00       	mov    %eax,0x1778
	close(fd);
     1fb:	e8 10 0a 00 00       	call   c10 <close>
}
     200:	83 c4 7c             	add    $0x7c,%esp
     203:	5b                   	pop    %ebx
     204:	5e                   	pop    %esi
     205:	5f                   	pop    %edi
     206:	5d                   	pop    %ebp
     207:	c3                   	ret    


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     208:	80 7d d1 00          	cmpb   $0x0,-0x2f(%ebp)
     20c:	8d 45 d1             	lea    -0x2f(%ebp),%eax
     20f:	0f 84 6b ff ff ff    	je     180 <readFromFile+0x140>
     215:	8d 76 00             	lea    0x0(%esi),%esi
		point++;
     218:	83 c0 01             	add    $0x1,%eax


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     21b:	80 38 00             	cmpb   $0x0,(%eax)
     21e:	75 f8                	jne    218 <readFromFile+0x1d8>
     220:	e9 5b ff ff ff       	jmp    180 <readFromFile+0x140>
     225:	8d 76 00             	lea    0x0(%esi),%esi
     228:	80 7d dc 00          	cmpb   $0x0,-0x24(%ebp)
     22c:	8d 45 dc             	lea    -0x24(%ebp),%eax
     22f:	90                   	nop
     230:	0f 84 4a ff ff ff    	je     180 <readFromFile+0x140>
     236:	66 90                	xchg   %ax,%ax
		point++;
     238:	83 c0 01             	add    $0x1,%eax


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     23b:	80 38 00             	cmpb   $0x0,(%eax)
     23e:	66 90                	xchg   %ax,%ax
     240:	75 f6                	jne    238 <readFromFile+0x1f8>
     242:	e9 39 ff ff ff       	jmp    180 <readFromFile+0x140>
     247:	90                   	nop
					charCat(Bstr,readbuf);
				if(flag == 2)
					charCat(Hstr,readbuf);
				if(flag == 3)
					charCat(Rstr,readbuf);
				if(flag == 4)
     248:	83 fb 04             	cmp    $0x4,%ebx
     24b:	90                   	nop
     24c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     250:	75 1b                	jne    26d <readFromFile+0x22d>


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     252:	80 7d bb 00          	cmpb   $0x0,-0x45(%ebp)
     256:	8d 45 bb             	lea    -0x45(%ebp),%eax
     259:	0f 84 21 ff ff ff    	je     180 <readFromFile+0x140>
     25f:	90                   	nop
		point++;
     260:	83 c0 01             	add    $0x1,%eax


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     263:	80 38 00             	cmpb   $0x0,(%eax)
     266:	75 f8                	jne    260 <readFromFile+0x220>
     268:	e9 13 ff ff ff       	jmp    180 <readFromFile+0x140>
					charCat(Hstr,readbuf);
				if(flag == 3)
					charCat(Rstr,readbuf);
				if(flag == 4)
					charCat(Cstr,readbuf);
				if(flag == 5)
     26d:	83 fb 05             	cmp    $0x5,%ebx
     270:	0f 85 10 ff ff ff    	jne    186 <readFromFile+0x146>


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     276:	80 7d b0 00          	cmpb   $0x0,-0x50(%ebp)
     27a:	8d 45 b0             	lea    -0x50(%ebp),%eax
     27d:	8d 76 00             	lea    0x0(%esi),%esi
     280:	0f 84 fa fe ff ff    	je     180 <readFromFile+0x140>
     286:	66 90                	xchg   %ax,%ax
		point++;
     288:	83 c0 01             	add    $0x1,%eax


void
charCat(char* str, char c) {
	char* point = str;
	while((*point) != '\0') {
     28b:	80 38 00             	cmpb   $0x0,(%eax)
     28e:	75 f8                	jne    288 <readFromFile+0x248>
     290:	e9 eb fe ff ff       	jmp    180 <readFromFile+0x140>
     295:	8d 76 00             	lea    0x0(%esi),%esi
			flag = 1;
			counter++;
		}
		if(readbuf == 'H') {
			flag = 2;
			counter++;
     298:	83 45 94 01          	addl   $0x1,-0x6c(%ebp)
     29c:	bb 02 00 00 00       	mov    $0x2,%ebx
     2a1:	e9 72 fe ff ff       	jmp    118 <readFromFile+0xd8>
     2a6:	66 90                	xchg   %ax,%ax
	char readbuf;
	while(read(fd,&readbuf,1) > 0)
	{
		if(readbuf == 'B') {
			flag = 1;
			counter++;
     2a8:	83 45 94 01          	addl   $0x1,-0x6c(%ebp)
     2ac:	bb 01 00 00 00       	mov    $0x1,%ebx
     2b1:	e9 62 fe ff ff       	jmp    118 <readFromFile+0xd8>
     2b6:	66 90                	xchg   %ax,%ax
		}
		if(readbuf == 'R') {
			flag = 3;
			counter++;
		}
		if(readbuf == 'C') {
     2b8:	80 fa 43             	cmp    $0x43,%dl
     2bb:	75 27                	jne    2e4 <readFromFile+0x2a4>
			flag = 4;
			counter++;
     2bd:	83 45 94 01          	addl   $0x1,-0x6c(%ebp)
     2c1:	bb 04 00 00 00       	mov    $0x4,%ebx
     2c6:	e9 51 fe ff ff       	jmp    11c <readFromFile+0xdc>
	char Rstr[11] = "\0";;
	char Cstr[11] = "\0";;
	char totalRequestsstr[11];
	int fd = open("con.conf",O_RDONLY);
	if(fd < 0) {
		printf(2,"problem opening file");
     2cb:	c7 44 24 04 59 15 00 	movl   $0x1559,0x4(%esp)
     2d2:	00 
     2d3:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     2da:	e8 a1 0a 00 00       	call   d80 <printf>
		exit();
     2df:	e8 04 09 00 00       	call   be8 <exit>
		}
		if(readbuf == 'C') {
			flag = 4;
			counter++;
		}
		if(readbuf == 't') {
     2e4:	80 fa 74             	cmp    $0x74,%dl
     2e7:	0f 85 b1 fe ff ff    	jne    19e <readFromFile+0x15e>
			char teststr[12];
			read(fd,teststr,12);
     2ed:	8d 45 a4             	lea    -0x5c(%ebp),%eax
     2f0:	c7 44 24 08 0c 00 00 	movl   $0xc,0x8(%esp)
     2f7:	00 
     2f8:	89 44 24 04          	mov    %eax,0x4(%esp)
     2fc:	89 34 24             	mov    %esi,(%esp)
     2ff:	e8 fc 08 00 00       	call   c00 <read>
			if(strcmp(teststr, "otalRequests")==0) {
     304:	8d 45 a4             	lea    -0x5c(%ebp),%eax
     307:	c7 44 24 04 6e 15 00 	movl   $0x156e,0x4(%esp)
     30e:	00 
     30f:	89 04 24             	mov    %eax,(%esp)
     312:	e8 d9 06 00 00       	call   9f0 <strcmp>
     317:	85 c0                	test   %eax,%eax
     319:	0f 85 7f fe ff ff    	jne    19e <readFromFile+0x15e>
				flag = 5;
				counter++;
     31f:	83 45 94 01          	addl   $0x1,-0x6c(%ebp)
     323:	bb 05 00 00 00       	mov    $0x5,%ebx
     328:	0f b6 55 e7          	movzbl -0x19(%ebp),%edx
     32c:	e9 eb fd ff ff       	jmp    11c <readFromFile+0xdc>
     331:	eb 0d                	jmp    340 <main>
     333:	90                   	nop
     334:	90                   	nop
     335:	90                   	nop
     336:	90                   	nop
     337:	90                   	nop
     338:	90                   	nop
     339:	90                   	nop
     33a:	90                   	nop
     33b:	90                   	nop
     33c:	90                   	nop
     33d:	90                   	nop
     33e:	90                   	nop
     33f:	90                   	nop

00000340 <main>:
	C = atoi(Cstr);
	totalRequests = atoi(totalRequestsstr);
	close(fd);
}

int main() {
     340:	8d 4c 24 04          	lea    0x4(%esp),%ecx
     344:	83 e4 f0             	and    $0xfffffff0,%esp
     347:	ff 71 fc             	pushl  -0x4(%ecx)
     34a:	55                   	push   %ebp
     34b:	89 e5                	mov    %esp,%ebp
     34d:	56                   	push   %esi
     34e:	53                   	push   %ebx
     34f:	51                   	push   %ecx
     350:	83 ec 1c             	sub    $0x1c,%esp
	int i;
	void* ustack;
	readFromFile();
     353:	e8 e8 fc ff ff       	call   40 <readFromFile>
	//printf(1,"%d %d %d %d %d\n",B,H,R,C,totalRequests);
	filedes = open("ss2_log.txt",(O_WRONLY | O_CREATE));
     358:	c7 44 24 04 01 02 00 	movl   $0x201,0x4(%esp)
     35f:	00 
     360:	c7 04 24 7b 15 00 00 	movl   $0x157b,(%esp)
     367:	e8 bc 08 00 00       	call   c28 <open>
	if(filedes < 0) {
     36c:	85 c0                	test   %eax,%eax
int main() {
	int i;
	void* ustack;
	readFromFile();
	//printf(1,"%d %d %d %d %d\n",B,H,R,C,totalRequests);
	filedes = open("ss2_log.txt",(O_WRONLY | O_CREATE));
     36e:	a3 6c 17 00 00       	mov    %eax,0x176c
	if(filedes < 0) {
     373:	0f 88 f7 01 00 00    	js     570 <main+0x230>
		printf(2,"problem opening file\n");
		exit();
	}

	RBB = BB_create(R);
     379:	a1 a4 17 00 00       	mov    0x17a4,%eax
     37e:	89 04 24             	mov    %eax,(%esp)
     381:	e8 3a 11 00 00       	call   14c0 <BB_create>
     386:	a3 7c 17 00 00       	mov    %eax,0x177c
	CBB = BB_create(C);
     38b:	a1 9c 17 00 00       	mov    0x179c,%eax
     390:	89 04 24             	mov    %eax,(%esp)
     393:	e8 28 11 00 00       	call   14c0 <BB_create>
	dirtyCups = 0;
     398:	c7 05 80 17 00 00 00 	movl   $0x0,0x1780
     39f:	00 00 00 
	requests = 0;
     3a2:	c7 05 8c 17 00 00 00 	movl   $0x0,0x178c
     3a9:	00 00 00 
		printf(2,"problem opening file\n");
		exit();
	}

	RBB = BB_create(R);
	CBB = BB_create(C);
     3ac:	a3 a8 17 00 00       	mov    %eax,0x17a8
	dirtyCups = 0;
	requests = 0;

	binsem_counter_dirty_cups = binary_sem_create();
     3b1:	e8 fa 08 00 00       	call   cb0 <binary_sem_create>
     3b6:	a3 70 17 00 00       	mov    %eax,0x1770
	binsem_counter_requests = binary_sem_create();
     3bb:	e8 f0 08 00 00       	call   cb0 <binary_sem_create>
     3c0:	a3 74 17 00 00       	mov    %eax,0x1774
	binsem_wake_busboy = binary_sem_create();
     3c5:	e8 e6 08 00 00       	call   cb0 <binary_sem_create>
     3ca:	a3 84 17 00 00       	mov    %eax,0x1784
	binsem_on_cups_array = binary_sem_create();
     3cf:	e8 dc 08 00 00       	call   cb0 <binary_sem_create>
     3d4:	a3 88 17 00 00       	mov    %eax,0x1788
	binsem_synchronize_printing = binary_sem_create();
     3d9:	e8 d2 08 00 00       	call   cb0 <binary_sem_create>
     3de:	a3 90 17 00 00       	mov    %eax,0x1790
	binary_sem_down(binsem_wake_busboy);
     3e3:	a1 84 17 00 00       	mov    0x1784,%eax
     3e8:	89 04 24             	mov    %eax,(%esp)
     3eb:	e8 c8 08 00 00       	call   cb8 <binary_sem_down>

	cups = malloc(sizeof(Cup) * C);
     3f0:	a1 9c 17 00 00       	mov    0x179c,%eax
     3f5:	c1 e0 02             	shl    $0x2,%eax
     3f8:	89 04 24             	mov    %eax,(%esp)
     3fb:	e8 20 0c 00 00       	call   1020 <malloc>
	for(i=0;i<C;i++) {
     400:	8b 15 9c 17 00 00    	mov    0x179c,%edx
     406:	85 d2                	test   %edx,%edx
	binsem_wake_busboy = binary_sem_create();
	binsem_on_cups_array = binary_sem_create();
	binsem_synchronize_printing = binary_sem_create();
	binary_sem_down(binsem_wake_busboy);

	cups = malloc(sizeof(Cup) * C);
     408:	a3 98 17 00 00       	mov    %eax,0x1798
	for(i=0;i<C;i++) {
     40d:	7e 3e                	jle    44d <main+0x10d>
     40f:	31 db                	xor    %ebx,%ebx
     411:	eb 0a                	jmp    41d <main+0xdd>
     413:	90                   	nop
     414:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     418:	a1 98 17 00 00       	mov    0x1798,%eax
		cups[i].clean = 1;
     41d:	c7 04 98 01 00 00 00 	movl   $0x1,(%eax,%ebx,4)
		//printf(1,"im here %d",C);
		semaphore_put(CBB, (void*)(&(cups[i])));
     424:	a1 a8 17 00 00       	mov    0x17a8,%eax
	binsem_on_cups_array = binary_sem_create();
	binsem_synchronize_printing = binary_sem_create();
	binary_sem_down(binsem_wake_busboy);

	cups = malloc(sizeof(Cup) * C);
	for(i=0;i<C;i++) {
     429:	8d 14 9d 00 00 00 00 	lea    0x0(,%ebx,4),%edx
		cups[i].clean = 1;
		//printf(1,"im here %d",C);
		semaphore_put(CBB, (void*)(&(cups[i])));
     430:	03 15 98 17 00 00    	add    0x1798,%edx
	binsem_on_cups_array = binary_sem_create();
	binsem_synchronize_printing = binary_sem_create();
	binary_sem_down(binsem_wake_busboy);

	cups = malloc(sizeof(Cup) * C);
	for(i=0;i<C;i++) {
     436:	83 c3 01             	add    $0x1,%ebx
		cups[i].clean = 1;
		//printf(1,"im here %d",C);
		semaphore_put(CBB, (void*)(&(cups[i])));
     439:	89 54 24 04          	mov    %edx,0x4(%esp)
     43d:	89 04 24             	mov    %eax,(%esp)
     440:	e8 eb 0f 00 00       	call   1430 <semaphore_put>
	binsem_on_cups_array = binary_sem_create();
	binsem_synchronize_printing = binary_sem_create();
	binary_sem_down(binsem_wake_busboy);

	cups = malloc(sizeof(Cup) * C);
	for(i=0;i<C;i++) {
     445:	39 1d 9c 17 00 00    	cmp    %ebx,0x179c
     44b:	7f cb                	jg     418 <main+0xd8>
		cups[i].clean = 1;
		//printf(1,"im here %d",C);
		semaphore_put(CBB, (void*)(&(cups[i])));
	}

	int tid[B+H+1];
     44d:	a1 94 17 00 00       	mov    0x1794,%eax
     452:	03 05 a0 17 00 00    	add    0x17a0,%eax
     458:	8d 14 85 22 00 00 00 	lea    0x22(,%eax,4),%edx
     45f:	83 e2 f0             	and    $0xfffffff0,%edx
     462:	29 d4                	sub    %edx,%esp
     464:	8d 74 24 1b          	lea    0x1b(%esp),%esi
     468:	83 e6 f0             	and    $0xfffffff0,%esi
	for(i=0;i<(B+H+1);i++) {
     46b:	85 c0                	test   %eax,%eax
     46d:	0f 88 ca 00 00 00    	js     53d <main+0x1fd>
     473:	31 db                	xor    %ebx,%ebx
     475:	eb 38                	jmp    4af <main+0x16f>
     477:	90                   	nop
		}
		else {
			if(i<B) {
				tid[i] = thread_create(bartender ,ustack, STK_SIZE);
			}
			else if((i>=B) && (i<(B+H))) {
     478:	03 15 a0 17 00 00    	add    0x17a0,%edx
     47e:	39 da                	cmp    %ebx,%edx
     480:	7f 6e                	jg     4f0 <main+0x1b0>
				tid[i] = thread_create(hostess ,ustack, STK_SIZE);
			}
			else {
				tid[i] = thread_create(busboy ,ustack, STK_SIZE);
     482:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
     489:	00 
     48a:	89 44 24 04          	mov    %eax,0x4(%esp)
     48e:	c7 04 24 20 07 00 00 	movl   $0x720,(%esp)
     495:	e8 ee 07 00 00       	call   c88 <thread_create>
     49a:	89 04 9e             	mov    %eax,(%esi,%ebx,4)
		//printf(1,"im here %d",C);
		semaphore_put(CBB, (void*)(&(cups[i])));
	}

	int tid[B+H+1];
	for(i=0;i<(B+H+1);i++) {
     49d:	a1 a0 17 00 00       	mov    0x17a0,%eax
     4a2:	83 c3 01             	add    $0x1,%ebx
     4a5:	03 05 94 17 00 00    	add    0x1794,%eax
     4ab:	39 d8                	cmp    %ebx,%eax
     4ad:	7c 61                	jl     510 <main+0x1d0>
		if((ustack = malloc(STK_SIZE)) <= 0) {
     4af:	c7 04 24 00 10 00 00 	movl   $0x1000,(%esp)
     4b6:	e8 65 0b 00 00       	call   1020 <malloc>
     4bb:	85 c0                	test   %eax,%eax
     4bd:	0f 84 8d 00 00 00    	je     550 <main+0x210>
			printf(2,"cant malloc the stack for the thread\n");
			exit();
		}
		else {
			if(i<B) {
     4c3:	8b 15 94 17 00 00    	mov    0x1794,%edx
     4c9:	39 da                	cmp    %ebx,%edx
     4cb:	7e ab                	jle    478 <main+0x138>
				tid[i] = thread_create(bartender ,ustack, STK_SIZE);
     4cd:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
     4d4:	00 
     4d5:	89 44 24 04          	mov    %eax,0x4(%esp)
     4d9:	c7 04 24 d0 08 00 00 	movl   $0x8d0,(%esp)
     4e0:	e8 a3 07 00 00       	call   c88 <thread_create>
     4e5:	89 04 9e             	mov    %eax,(%esi,%ebx,4)
     4e8:	eb b3                	jmp    49d <main+0x15d>
     4ea:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
			}
			else if((i>=B) && (i<(B+H))) {
				tid[i] = thread_create(hostess ,ustack, STK_SIZE);
     4f0:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
     4f7:	00 
     4f8:	89 44 24 04          	mov    %eax,0x4(%esp)
     4fc:	c7 04 24 c0 07 00 00 	movl   $0x7c0,(%esp)
     503:	e8 80 07 00 00       	call   c88 <thread_create>
     508:	89 04 9e             	mov    %eax,(%esi,%ebx,4)
		}
		else {
			if(i<B) {
				tid[i] = thread_create(bartender ,ustack, STK_SIZE);
			}
			else if((i>=B) && (i<(B+H))) {
     50b:	eb 90                	jmp    49d <main+0x15d>
     50d:	8d 76 00             	lea    0x0(%esi),%esi
			else {
				tid[i] = thread_create(busboy ,ustack, STK_SIZE);
			}
		}
	}
	for(i=0;i<(B+H+1);i++) {
     510:	85 c0                	test   %eax,%eax
     512:	78 29                	js     53d <main+0x1fd>
     514:	31 db                	xor    %ebx,%ebx
     516:	66 90                	xchg   %ax,%ax
		thread_join(tid[i],0);
     518:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     51f:	00 
     520:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
			else {
				tid[i] = thread_create(busboy ,ustack, STK_SIZE);
			}
		}
	}
	for(i=0;i<(B+H+1);i++) {
     523:	83 c3 01             	add    $0x1,%ebx
		thread_join(tid[i],0);
     526:	89 04 24             	mov    %eax,(%esp)
     529:	e8 7a 07 00 00       	call   ca8 <thread_join>
			else {
				tid[i] = thread_create(busboy ,ustack, STK_SIZE);
			}
		}
	}
	for(i=0;i<(B+H+1);i++) {
     52e:	a1 a0 17 00 00       	mov    0x17a0,%eax
     533:	03 05 94 17 00 00    	add    0x1794,%eax
     539:	39 d8                	cmp    %ebx,%eax
     53b:	7d db                	jge    518 <main+0x1d8>
		thread_join(tid[i],0);
	}
	close(filedes);
     53d:	a1 6c 17 00 00       	mov    0x176c,%eax
     542:	89 04 24             	mov    %eax,(%esp)
     545:	e8 c6 06 00 00       	call   c10 <close>
	exit();
     54a:	e8 99 06 00 00       	call   be8 <exit>
     54f:	90                   	nop
	}

	int tid[B+H+1];
	for(i=0;i<(B+H+1);i++) {
		if((ustack = malloc(STK_SIZE)) <= 0) {
			printf(2,"cant malloc the stack for the thread\n");
     550:	c7 44 24 04 a8 15 00 	movl   $0x15a8,0x4(%esp)
     557:	00 
     558:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     55f:	e8 1c 08 00 00       	call   d80 <printf>
			exit();
     564:	e8 7f 06 00 00       	call   be8 <exit>
     569:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
	void* ustack;
	readFromFile();
	//printf(1,"%d %d %d %d %d\n",B,H,R,C,totalRequests);
	filedes = open("ss2_log.txt",(O_WRONLY | O_CREATE));
	if(filedes < 0) {
		printf(2,"problem opening file\n");
     570:	c7 44 24 04 87 15 00 	movl   $0x1587,0x4(%esp)
     577:	00 
     578:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     57f:	e8 fc 07 00 00       	call   d80 <printf>
		exit();
     584:	e8 5f 06 00 00       	call   be8 <exit>
     589:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00000590 <washCups>:

Cup* getCleanCup() {
	return (Cup*)semaphore_pop(CBB);
}

int washCups() {
     590:	55                   	push   %ebp
     591:	89 e5                	mov    %esp,%ebp
     593:	57                   	push   %edi
     594:	56                   	push   %esi
     595:	53                   	push   %ebx
     596:	83 ec 2c             	sub    $0x2c,%esp
	int i;
	int counter = 0;
	binary_sem_down(binsem_on_cups_array);
     599:	a1 88 17 00 00       	mov    0x1788,%eax
     59e:	89 04 24             	mov    %eax,(%esp)
     5a1:	e8 12 07 00 00       	call   cb8 <binary_sem_down>
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
     5a6:	a1 9c 17 00 00       	mov    0x179c,%eax
     5ab:	85 c0                	test   %eax,%eax
     5ad:	0f 8e 06 01 00 00    	jle    6b9 <washCups+0x129>
     5b3:	d9 7d e2             	fnstcw -0x1e(%ebp)
     5b6:	31 ff                	xor    %edi,%edi
     5b8:	31 db                	xor    %ebx,%ebx
     5ba:	89 45 e4             	mov    %eax,-0x1c(%ebp)
     5bd:	db 45 e4             	fildl  -0x1c(%ebp)
     5c0:	dd 05 90 16 00 00    	fldl   0x1690
     5c6:	0f b7 45 e2          	movzwl -0x1e(%ebp),%eax
     5ca:	de c9                	fmulp  %st,%st(1)
     5cc:	b4 0c                	mov    $0xc,%ah
     5ce:	66 89 45 e0          	mov    %ax,-0x20(%ebp)
     5d2:	d9 6d e0             	fldcw  -0x20(%ebp)
     5d5:	db 5d e4             	fistpl -0x1c(%ebp)
     5d8:	d9 6d e2             	fldcw  -0x1e(%ebp)
     5db:	8b 55 e4             	mov    -0x1c(%ebp),%edx
     5de:	85 d2                	test   %edx,%edx
     5e0:	7f 33                	jg     615 <washCups+0x85>
     5e2:	e9 c4 00 00 00       	jmp    6ab <washCups+0x11b>
     5e7:	90                   	nop
     5e8:	d9 7d e2             	fnstcw -0x1e(%ebp)
     5eb:	89 45 e4             	mov    %eax,-0x1c(%ebp)
     5ee:	db 45 e4             	fildl  -0x1c(%ebp)
     5f1:	dc 0d 90 16 00 00    	fmull  0x1690
     5f7:	0f b7 45 e2          	movzwl -0x1e(%ebp),%eax
     5fb:	b4 0c                	mov    $0xc,%ah
     5fd:	66 89 45 e0          	mov    %ax,-0x20(%ebp)
     601:	d9 6d e0             	fldcw  -0x20(%ebp)
     604:	db 5d e4             	fistpl -0x1c(%ebp)
     607:	d9 6d e2             	fldcw  -0x1e(%ebp)
     60a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
     60d:	39 d7                	cmp    %edx,%edi
     60f:	0f 8d 96 00 00 00    	jge    6ab <washCups+0x11b>
		if(cups[i].clean != 1) {
     615:	a1 98 17 00 00       	mov    0x1798,%eax

int washCups() {
	int i;
	int counter = 0;
	binary_sem_down(binsem_on_cups_array);
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
     61a:	8d 34 9d 00 00 00 00 	lea    0x0(,%ebx,4),%esi
		if(cups[i].clean != 1) {
     621:	01 f0                	add    %esi,%eax
     623:	83 38 01             	cmpl   $0x1,(%eax)
     626:	74 41                	je     669 <washCups+0xd9>
			cups[i].clean = 1;
     628:	c7 00 01 00 00 00    	movl   $0x1,(%eax)
			binary_sem_down(binsem_counter_dirty_cups);
     62e:	a1 70 17 00 00       	mov    0x1770,%eax
			dirtyCups--;
			binary_sem_up(binsem_counter_dirty_cups);
			counter++;
     633:	83 c7 01             	add    $0x1,%edi
	int counter = 0;
	binary_sem_down(binsem_on_cups_array);
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
		if(cups[i].clean != 1) {
			cups[i].clean = 1;
			binary_sem_down(binsem_counter_dirty_cups);
     636:	89 04 24             	mov    %eax,(%esp)
     639:	e8 7a 06 00 00       	call   cb8 <binary_sem_down>
			dirtyCups--;
			binary_sem_up(binsem_counter_dirty_cups);
     63e:	a1 70 17 00 00       	mov    0x1770,%eax
	binary_sem_down(binsem_on_cups_array);
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
		if(cups[i].clean != 1) {
			cups[i].clean = 1;
			binary_sem_down(binsem_counter_dirty_cups);
			dirtyCups--;
     643:	83 2d 80 17 00 00 01 	subl   $0x1,0x1780
			binary_sem_up(binsem_counter_dirty_cups);
     64a:	89 04 24             	mov    %eax,(%esp)
     64d:	e8 6e 06 00 00       	call   cc0 <binary_sem_up>
			counter++;
			semaphore_put(CBB,(void*)(&cups[i]));
     652:	a1 a8 17 00 00       	mov    0x17a8,%eax
     657:	03 35 98 17 00 00    	add    0x1798,%esi
     65d:	89 04 24             	mov    %eax,(%esp)
     660:	89 74 24 04          	mov    %esi,0x4(%esp)
     664:	e8 c7 0d 00 00       	call   1430 <semaphore_put>
		}
		binary_sem_up(binsem_on_cups_array);
     669:	a1 88 17 00 00       	mov    0x1788,%eax

int washCups() {
	int i;
	int counter = 0;
	binary_sem_down(binsem_on_cups_array);
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
     66e:	83 c3 01             	add    $0x1,%ebx
			dirtyCups--;
			binary_sem_up(binsem_counter_dirty_cups);
			counter++;
			semaphore_put(CBB,(void*)(&cups[i]));
		}
		binary_sem_up(binsem_on_cups_array);
     671:	89 04 24             	mov    %eax,(%esp)
     674:	e8 47 06 00 00       	call   cc0 <binary_sem_up>

int washCups() {
	int i;
	int counter = 0;
	binary_sem_down(binsem_on_cups_array);
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
     679:	a1 9c 17 00 00       	mov    0x179c,%eax
     67e:	39 d8                	cmp    %ebx,%eax
     680:	0f 8f 62 ff ff ff    	jg     5e8 <washCups+0x58>
     686:	d9 7d e2             	fnstcw -0x1e(%ebp)
     689:	89 45 e4             	mov    %eax,-0x1c(%ebp)
     68c:	db 45 e4             	fildl  -0x1c(%ebp)
     68f:	dc 0d 90 16 00 00    	fmull  0x1690
     695:	0f b7 45 e2          	movzwl -0x1e(%ebp),%eax
     699:	b4 0c                	mov    $0xc,%ah
     69b:	66 89 45 e0          	mov    %ax,-0x20(%ebp)
     69f:	d9 6d e0             	fldcw  -0x20(%ebp)
     6a2:	db 5d e4             	fistpl -0x1c(%ebp)
     6a5:	d9 6d e2             	fldcw  -0x1e(%ebp)
     6a8:	8b 55 e4             	mov    -0x1c(%ebp),%edx
			counter++;
			semaphore_put(CBB,(void*)(&cups[i]));
		}
		binary_sem_up(binsem_on_cups_array);
	}
	if(counter != ((int)(C*0.85))) {
     6ab:	31 c0                	xor    %eax,%eax
     6ad:	39 d7                	cmp    %edx,%edi
     6af:	75 31                	jne    6e2 <washCups+0x152>
		printf(2,"less or more than 85% cups!! percentage is: %d",((int)(counter*0.85)));
		return -1;
	}
	return 0;
}
     6b1:	83 c4 2c             	add    $0x2c,%esp
     6b4:	5b                   	pop    %ebx
     6b5:	5e                   	pop    %esi
     6b6:	5f                   	pop    %edi
     6b7:	5d                   	pop    %ebp
     6b8:	c3                   	ret    

int washCups() {
	int i;
	int counter = 0;
	binary_sem_down(binsem_on_cups_array);
	for(i=0;(i<C && counter<((int)(C*0.85)));i++) {
     6b9:	d9 7d e2             	fnstcw -0x1e(%ebp)
     6bc:	31 ff                	xor    %edi,%edi
     6be:	89 45 e4             	mov    %eax,-0x1c(%ebp)
     6c1:	db 45 e4             	fildl  -0x1c(%ebp)
     6c4:	dc 0d 90 16 00 00    	fmull  0x1690
     6ca:	0f b7 45 e2          	movzwl -0x1e(%ebp),%eax
     6ce:	b4 0c                	mov    $0xc,%ah
     6d0:	66 89 45 e0          	mov    %ax,-0x20(%ebp)
     6d4:	d9 6d e0             	fldcw  -0x20(%ebp)
     6d7:	db 5d e4             	fistpl -0x1c(%ebp)
     6da:	d9 6d e2             	fldcw  -0x1e(%ebp)
     6dd:	8b 55 e4             	mov    -0x1c(%ebp),%edx
     6e0:	eb c9                	jmp    6ab <washCups+0x11b>
			semaphore_put(CBB,(void*)(&cups[i]));
		}
		binary_sem_up(binsem_on_cups_array);
	}
	if(counter != ((int)(C*0.85))) {
		printf(2,"less or more than 85% cups!! percentage is: %d",((int)(counter*0.85)));
     6e2:	89 7d e4             	mov    %edi,-0x1c(%ebp)
     6e5:	db 45 e4             	fildl  -0x1c(%ebp)
     6e8:	dc 0d 90 16 00 00    	fmull  0x1690
     6ee:	c7 44 24 04 d0 15 00 	movl   $0x15d0,0x4(%esp)
     6f5:	00 
     6f6:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     6fd:	d9 6d e0             	fldcw  -0x20(%ebp)
     700:	db 5c 24 08          	fistpl 0x8(%esp)
     704:	d9 6d e2             	fldcw  -0x1e(%ebp)
     707:	e8 74 06 00 00       	call   d80 <printf>
     70c:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
		return -1;
     711:	eb 9e                	jmp    6b1 <washCups+0x121>
     713:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     719:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000720 <busboy>:
	thread_exit(0);
	return 0;
}

void*
busboy() {
     720:	55                   	push   %ebp
     721:	89 e5                	mov    %esp,%ebp
     723:	53                   	push   %ebx
     724:	83 ec 24             	sub    $0x24,%esp
     727:	eb 68                	jmp    791 <busboy+0x71>
     729:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
		binary_sem_down(binsem_wake_busboy);
		if(washCups() < 0) {
			printf(2,"problem with the washing of cups");
			exit();
		}
		binary_sem_down(binsem_synchronize_printing);
     730:	a1 90 17 00 00       	mov    0x1790,%eax
     735:	89 04 24             	mov    %eax,(%esp)
     738:	e8 7b 05 00 00       	call   cb8 <binary_sem_down>
		printf(filedes,"Busboy %d added %d clean cups.\n",thread_getid(),(int)(C*0.85));
     73d:	d9 7d f6             	fnstcw -0xa(%ebp)
     740:	db 05 9c 17 00 00    	fildl  0x179c
     746:	dc 0d 90 16 00 00    	fmull  0x1690
     74c:	0f b7 45 f6          	movzwl -0xa(%ebp),%eax
     750:	b4 0c                	mov    $0xc,%ah
     752:	66 89 45 f4          	mov    %ax,-0xc(%ebp)
     756:	d9 6d f4             	fldcw  -0xc(%ebp)
     759:	db 5d f0             	fistpl -0x10(%ebp)
     75c:	d9 6d f6             	fldcw  -0xa(%ebp)
     75f:	8b 5d f0             	mov    -0x10(%ebp),%ebx
     762:	e8 29 05 00 00       	call   c90 <thread_getid>
     767:	c7 44 24 04 24 16 00 	movl   $0x1624,0x4(%esp)
     76e:	00 
     76f:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
     773:	89 44 24 08          	mov    %eax,0x8(%esp)
     777:	a1 6c 17 00 00       	mov    0x176c,%eax
     77c:	89 04 24             	mov    %eax,(%esp)
     77f:	e8 fc 05 00 00       	call   d80 <printf>
		binary_sem_up(binsem_synchronize_printing);
     784:	a1 90 17 00 00       	mov    0x1790,%eax
     789:	89 04 24             	mov    %eax,(%esp)
     78c:	e8 2f 05 00 00       	call   cc0 <binary_sem_up>
}

void*
busboy() {
	while(1) {
		binary_sem_down(binsem_wake_busboy);
     791:	a1 84 17 00 00       	mov    0x1784,%eax
     796:	89 04 24             	mov    %eax,(%esp)
     799:	e8 1a 05 00 00       	call   cb8 <binary_sem_down>
		if(washCups() < 0) {
     79e:	e8 ed fd ff ff       	call   590 <washCups>
     7a3:	85 c0                	test   %eax,%eax
     7a5:	79 89                	jns    730 <busboy+0x10>
			printf(2,"problem with the washing of cups");
     7a7:	c7 44 24 04 00 16 00 	movl   $0x1600,0x4(%esp)
     7ae:	00 
     7af:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
     7b6:	e8 c5 05 00 00       	call   d80 <printf>
			exit();
     7bb:	e8 28 04 00 00       	call   be8 <exit>

000007c0 <hostess>:
		sleep(10);
	}
}

void*
hostess() {
     7c0:	55                   	push   %ebp
     7c1:	89 e5                	mov    %esp,%ebp
     7c3:	56                   	push   %esi
     7c4:	53                   	push   %ebx
     7c5:	83 ec 10             	sub    $0x10,%esp
	while(requests < totalRequests) {
     7c8:	a1 8c 17 00 00       	mov    0x178c,%eax
     7cd:	3b 05 78 17 00 00    	cmp    0x1778,%eax
     7d3:	0f 8d a1 00 00 00    	jge    87a <hostess+0xba>
     7d9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
		binary_sem_down(binsem_counter_requests);
     7e0:	a1 74 17 00 00       	mov    0x1774,%eax
     7e5:	89 04 24             	mov    %eax,(%esp)
     7e8:	e8 cb 04 00 00       	call   cb8 <binary_sem_down>
		Request* req = malloc(sizeof(Request));
     7ed:	c7 04 24 04 00 00 00 	movl   $0x4,(%esp)
     7f4:	e8 27 08 00 00       	call   1020 <malloc>
     7f9:	89 c3                	mov    %eax,%ebx
		requests++;
     7fb:	a1 8c 17 00 00       	mov    0x178c,%eax
     800:	83 c0 01             	add    $0x1,%eax
     803:	a3 8c 17 00 00       	mov    %eax,0x178c
		req->id = requests;
     808:	89 03                	mov    %eax,(%ebx)
		binary_sem_down(binsem_synchronize_printing);
     80a:	a1 90 17 00 00       	mov    0x1790,%eax
     80f:	89 04 24             	mov    %eax,(%esp)
     812:	e8 a1 04 00 00       	call   cb8 <binary_sem_down>
		printf(filedes,"Hostess %d added a new request #%d\n",thread_getid(),req->id);
     817:	8b 33                	mov    (%ebx),%esi
     819:	e8 72 04 00 00       	call   c90 <thread_getid>
     81e:	c7 44 24 04 44 16 00 	movl   $0x1644,0x4(%esp)
     825:	00 
     826:	89 74 24 0c          	mov    %esi,0xc(%esp)
     82a:	89 44 24 08          	mov    %eax,0x8(%esp)
     82e:	a1 6c 17 00 00       	mov    0x176c,%eax
     833:	89 04 24             	mov    %eax,(%esp)
     836:	e8 45 05 00 00       	call   d80 <printf>
		binary_sem_up(binsem_synchronize_printing);
     83b:	a1 90 17 00 00       	mov    0x1790,%eax
     840:	89 04 24             	mov    %eax,(%esp)
     843:	e8 78 04 00 00       	call   cc0 <binary_sem_up>
		addNewRequest(req);
     848:	89 1c 24             	mov    %ebx,(%esp)
     84b:	e8 d0 f7 ff ff       	call   20 <addNewRequest>
		binary_sem_up(binsem_counter_requests);
     850:	a1 74 17 00 00       	mov    0x1774,%eax
     855:	89 04 24             	mov    %eax,(%esp)
     858:	e8 63 04 00 00       	call   cc0 <binary_sem_up>
		sleep(10);
     85d:	c7 04 24 0a 00 00 00 	movl   $0xa,(%esp)
     864:	e8 0f 04 00 00       	call   c78 <sleep>
	}
}

void*
hostess() {
	while(requests < totalRequests) {
     869:	a1 8c 17 00 00       	mov    0x178c,%eax
     86e:	3b 05 78 17 00 00    	cmp    0x1778,%eax
     874:	0f 8c 66 ff ff ff    	jl     7e0 <hostess+0x20>
		addNewRequest(req);
		binary_sem_up(binsem_counter_requests);
		sleep(10);
	}
	//printf(1,"exit hostess\n");
	thread_exit(0);
     87a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
     881:	e8 1a 04 00 00       	call   ca0 <thread_exit>
	return 0;
}
     886:	83 c4 10             	add    $0x10,%esp
     889:	31 c0                	xor    %eax,%eax
     88b:	5b                   	pop    %ebx
     88c:	5e                   	pop    %esi
     88d:	5d                   	pop    %ebp
     88e:	c3                   	ret    
     88f:	90                   	nop

00000890 <getRequest>:

void addNewRequest( Request* newReq) {
	semaphore_put(RBB,(void*)newReq);
}

Request* getRequest() {
     890:	55                   	push   %ebp
     891:	89 e5                	mov    %esp,%ebp
     893:	83 ec 18             	sub    $0x18,%esp
	return (Request*)semaphore_pop(RBB);
     896:	a1 7c 17 00 00       	mov    0x177c,%eax
     89b:	89 04 24             	mov    %eax,(%esp)
     89e:	e8 7d 0a 00 00       	call   1320 <semaphore_pop>
}
     8a3:	c9                   	leave  
     8a4:	c3                   	ret    
     8a5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     8a9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000008b0 <getCleanCup>:
int binsem_wake_busboy; //lock on the waking and sleeping of the busboy to clean the cups
int binsem_on_cups_array; //lock on the array of cups
int filedes; //file descriptor of the log file
int binsem_synchronize_printing; //synchornization of the writing to the log file

Cup* getCleanCup() {
     8b0:	55                   	push   %ebp
     8b1:	89 e5                	mov    %esp,%ebp
     8b3:	83 ec 18             	sub    $0x18,%esp
	return (Cup*)semaphore_pop(CBB);
     8b6:	a1 a8 17 00 00       	mov    0x17a8,%eax
     8bb:	89 04 24             	mov    %eax,(%esp)
     8be:	e8 5d 0a 00 00       	call   1320 <semaphore_pop>
}
     8c3:	c9                   	leave  
     8c4:	c3                   	ret    
     8c5:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     8c9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000008d0 <bartender>:
Request* getRequest() {
	return (Request*)semaphore_pop(RBB);
}

void*
bartender() {
     8d0:	55                   	push   %ebp
     8d1:	89 e5                	mov    %esp,%ebp
     8d3:	56                   	push   %esi
     8d4:	53                   	push   %ebx
     8d5:	83 ec 20             	sub    $0x20,%esp
     8d8:	eb 67                	jmp    941 <bartender+0x71>
     8da:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
		dirtyCups++;
		cup->clean = 0;
		if(dirtyCups == ((int)(C*0.85))) {
			binary_sem_up(binsem_wake_busboy);
		}
		binary_sem_up(binsem_counter_dirty_cups);
     8e0:	a1 70 17 00 00       	mov    0x1770,%eax
     8e5:	89 04 24             	mov    %eax,(%esp)
     8e8:	e8 d3 03 00 00       	call   cc0 <binary_sem_up>
		binary_sem_down(binsem_synchronize_printing);
     8ed:	a1 90 17 00 00       	mov    0x1790,%eax
     8f2:	89 04 24             	mov    %eax,(%esp)
     8f5:	e8 be 03 00 00       	call   cb8 <binary_sem_down>
		printf(filedes,"Bartender %d completed request #%d\n",thread_getid(),req->id);
     8fa:	8b 33                	mov    (%ebx),%esi
     8fc:	e8 8f 03 00 00       	call   c90 <thread_getid>
     901:	c7 44 24 04 68 16 00 	movl   $0x1668,0x4(%esp)
     908:	00 
     909:	89 74 24 0c          	mov    %esi,0xc(%esp)
     90d:	89 44 24 08          	mov    %eax,0x8(%esp)
     911:	a1 6c 17 00 00       	mov    0x176c,%eax
     916:	89 04 24             	mov    %eax,(%esp)
     919:	e8 62 04 00 00       	call   d80 <printf>
		binary_sem_up(binsem_synchronize_printing);
     91e:	a1 90 17 00 00       	mov    0x1790,%eax
     923:	89 04 24             	mov    %eax,(%esp)
     926:	e8 95 03 00 00       	call   cc0 <binary_sem_up>
		if(req->id == totalRequests) {
     92b:	8b 03                	mov    (%ebx),%eax
     92d:	3b 05 78 17 00 00    	cmp    0x1778,%eax
     933:	74 7b                	je     9b0 <bartender+0xe0>
                    exit_all_threads();//need to leave the main process on so he can do thread_join
		}
		sleep(10);
     935:	c7 04 24 0a 00 00 00 	movl   $0xa,(%esp)
     93c:	e8 37 03 00 00       	call   c78 <sleep>
}

void*
bartender() {
	while(1) {
		Request* req = getRequest();
     941:	e8 4a ff ff ff       	call   890 <getRequest>
     946:	89 c3                	mov    %eax,%ebx

		binary_sem_down(binsem_counter_dirty_cups);
     948:	a1 70 17 00 00       	mov    0x1770,%eax
     94d:	89 04 24             	mov    %eax,(%esp)
     950:	e8 63 03 00 00       	call   cb8 <binary_sem_down>
		Cup* cup = getCleanCup();
     955:	e8 56 ff ff ff       	call   8b0 <getCleanCup>
		dirtyCups++;
     95a:	83 05 80 17 00 00 01 	addl   $0x1,0x1780
		cup->clean = 0;
     961:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
		if(dirtyCups == ((int)(C*0.85))) {
     967:	d9 7d f6             	fnstcw -0xa(%ebp)
     96a:	db 05 9c 17 00 00    	fildl  0x179c
     970:	dc 0d 90 16 00 00    	fmull  0x1690
     976:	0f b7 45 f6          	movzwl -0xa(%ebp),%eax
     97a:	b4 0c                	mov    $0xc,%ah
     97c:	66 89 45 f4          	mov    %ax,-0xc(%ebp)
     980:	d9 6d f4             	fldcw  -0xc(%ebp)
     983:	db 5d f0             	fistpl -0x10(%ebp)
     986:	d9 6d f6             	fldcw  -0xa(%ebp)
     989:	8b 45 f0             	mov    -0x10(%ebp),%eax
     98c:	3b 05 80 17 00 00    	cmp    0x1780,%eax
     992:	0f 85 48 ff ff ff    	jne    8e0 <bartender+0x10>
			binary_sem_up(binsem_wake_busboy);
     998:	a1 84 17 00 00       	mov    0x1784,%eax
     99d:	89 04 24             	mov    %eax,(%esp)
     9a0:	e8 1b 03 00 00       	call   cc0 <binary_sem_up>
     9a5:	e9 36 ff ff ff       	jmp    8e0 <bartender+0x10>
     9aa:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
		binary_sem_up(binsem_counter_dirty_cups);
		binary_sem_down(binsem_synchronize_printing);
		printf(filedes,"Bartender %d completed request #%d\n",thread_getid(),req->id);
		binary_sem_up(binsem_synchronize_printing);
		if(req->id == totalRequests) {
                    exit_all_threads();//need to leave the main process on so he can do thread_join
     9b0:	e8 1b 03 00 00       	call   cd0 <exit_all_threads>
     9b5:	8d 76 00             	lea    0x0(%esi),%esi
     9b8:	e9 78 ff ff ff       	jmp    935 <bartender+0x65>
     9bd:	90                   	nop
     9be:	90                   	nop
     9bf:	90                   	nop

000009c0 <strcpy>:
#include "user.h"
#include "x86.h"

char*
strcpy(char *s, char *t)
{
     9c0:	55                   	push   %ebp
     9c1:	31 d2                	xor    %edx,%edx
     9c3:	89 e5                	mov    %esp,%ebp
     9c5:	8b 45 08             	mov    0x8(%ebp),%eax
     9c8:	53                   	push   %ebx
     9c9:	8b 5d 0c             	mov    0xc(%ebp),%ebx
     9cc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *os;

  os = s;
  while((*s++ = *t++) != 0)
     9d0:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
     9d4:	88 0c 10             	mov    %cl,(%eax,%edx,1)
     9d7:	83 c2 01             	add    $0x1,%edx
     9da:	84 c9                	test   %cl,%cl
     9dc:	75 f2                	jne    9d0 <strcpy+0x10>
    ;
  return os;
}
     9de:	5b                   	pop    %ebx
     9df:	5d                   	pop    %ebp
     9e0:	c3                   	ret    
     9e1:	eb 0d                	jmp    9f0 <strcmp>
     9e3:	90                   	nop
     9e4:	90                   	nop
     9e5:	90                   	nop
     9e6:	90                   	nop
     9e7:	90                   	nop
     9e8:	90                   	nop
     9e9:	90                   	nop
     9ea:	90                   	nop
     9eb:	90                   	nop
     9ec:	90                   	nop
     9ed:	90                   	nop
     9ee:	90                   	nop
     9ef:	90                   	nop

000009f0 <strcmp>:

int
strcmp(const char *p, const char *q)
{
     9f0:	55                   	push   %ebp
     9f1:	89 e5                	mov    %esp,%ebp
     9f3:	53                   	push   %ebx
     9f4:	8b 4d 08             	mov    0x8(%ebp),%ecx
     9f7:	8b 55 0c             	mov    0xc(%ebp),%edx
  while(*p && *p == *q)
     9fa:	0f b6 01             	movzbl (%ecx),%eax
     9fd:	84 c0                	test   %al,%al
     9ff:	75 14                	jne    a15 <strcmp+0x25>
     a01:	eb 25                	jmp    a28 <strcmp+0x38>
     a03:	90                   	nop
     a04:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    p++, q++;
     a08:	83 c1 01             	add    $0x1,%ecx
     a0b:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     a0e:	0f b6 01             	movzbl (%ecx),%eax
     a11:	84 c0                	test   %al,%al
     a13:	74 13                	je     a28 <strcmp+0x38>
     a15:	0f b6 1a             	movzbl (%edx),%ebx
     a18:	38 d8                	cmp    %bl,%al
     a1a:	74 ec                	je     a08 <strcmp+0x18>
     a1c:	0f b6 db             	movzbl %bl,%ebx
     a1f:	0f b6 c0             	movzbl %al,%eax
     a22:	29 d8                	sub    %ebx,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
}
     a24:	5b                   	pop    %ebx
     a25:	5d                   	pop    %ebp
     a26:	c3                   	ret    
     a27:	90                   	nop
}

int
strcmp(const char *p, const char *q)
{
  while(*p && *p == *q)
     a28:	0f b6 1a             	movzbl (%edx),%ebx
     a2b:	31 c0                	xor    %eax,%eax
     a2d:	0f b6 db             	movzbl %bl,%ebx
     a30:	29 d8                	sub    %ebx,%eax
    p++, q++;
  return (uchar)*p - (uchar)*q;
}
     a32:	5b                   	pop    %ebx
     a33:	5d                   	pop    %ebp
     a34:	c3                   	ret    
     a35:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     a39:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000a40 <strlen>:

uint
strlen(char *s)
{
     a40:	55                   	push   %ebp
  int n;

  for(n = 0; s[n]; n++)
     a41:	31 d2                	xor    %edx,%edx
  return (uchar)*p - (uchar)*q;
}

uint
strlen(char *s)
{
     a43:	89 e5                	mov    %esp,%ebp
  int n;

  for(n = 0; s[n]; n++)
     a45:	31 c0                	xor    %eax,%eax
  return (uchar)*p - (uchar)*q;
}

uint
strlen(char *s)
{
     a47:	8b 4d 08             	mov    0x8(%ebp),%ecx
  int n;

  for(n = 0; s[n]; n++)
     a4a:	80 39 00             	cmpb   $0x0,(%ecx)
     a4d:	74 0c                	je     a5b <strlen+0x1b>
     a4f:	90                   	nop
     a50:	83 c2 01             	add    $0x1,%edx
     a53:	80 3c 11 00          	cmpb   $0x0,(%ecx,%edx,1)
     a57:	89 d0                	mov    %edx,%eax
     a59:	75 f5                	jne    a50 <strlen+0x10>
    ;
  return n;
}
     a5b:	5d                   	pop    %ebp
     a5c:	c3                   	ret    
     a5d:	8d 76 00             	lea    0x0(%esi),%esi

00000a60 <memset>:

void*
memset(void *dst, int c, uint n)
{
     a60:	55                   	push   %ebp
     a61:	89 e5                	mov    %esp,%ebp
     a63:	8b 55 08             	mov    0x8(%ebp),%edx
     a66:	57                   	push   %edi
}

static inline void
stosb(void *addr, int data, int cnt)
{
  asm volatile("cld; rep stosb" :
     a67:	8b 4d 10             	mov    0x10(%ebp),%ecx
     a6a:	8b 45 0c             	mov    0xc(%ebp),%eax
     a6d:	89 d7                	mov    %edx,%edi
     a6f:	fc                   	cld    
     a70:	f3 aa                	rep stos %al,%es:(%edi)
  stosb(dst, c, n);
  return dst;
}
     a72:	89 d0                	mov    %edx,%eax
     a74:	5f                   	pop    %edi
     a75:	5d                   	pop    %ebp
     a76:	c3                   	ret    
     a77:	89 f6                	mov    %esi,%esi
     a79:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000a80 <strchr>:

char*
strchr(const char *s, char c)
{
     a80:	55                   	push   %ebp
     a81:	89 e5                	mov    %esp,%ebp
     a83:	8b 45 08             	mov    0x8(%ebp),%eax
     a86:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  for(; *s; s++)
     a8a:	0f b6 10             	movzbl (%eax),%edx
     a8d:	84 d2                	test   %dl,%dl
     a8f:	75 11                	jne    aa2 <strchr+0x22>
     a91:	eb 15                	jmp    aa8 <strchr+0x28>
     a93:	90                   	nop
     a94:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     a98:	83 c0 01             	add    $0x1,%eax
     a9b:	0f b6 10             	movzbl (%eax),%edx
     a9e:	84 d2                	test   %dl,%dl
     aa0:	74 06                	je     aa8 <strchr+0x28>
    if(*s == c)
     aa2:	38 ca                	cmp    %cl,%dl
     aa4:	75 f2                	jne    a98 <strchr+0x18>
      return (char*) s;
  return 0;
}
     aa6:	5d                   	pop    %ebp
     aa7:	c3                   	ret    
}

char*
strchr(const char *s, char c)
{
  for(; *s; s++)
     aa8:	31 c0                	xor    %eax,%eax
    if(*s == c)
      return (char*) s;
  return 0;
}
     aaa:	5d                   	pop    %ebp
     aab:	90                   	nop
     aac:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     ab0:	c3                   	ret    
     ab1:	eb 0d                	jmp    ac0 <atoi>
     ab3:	90                   	nop
     ab4:	90                   	nop
     ab5:	90                   	nop
     ab6:	90                   	nop
     ab7:	90                   	nop
     ab8:	90                   	nop
     ab9:	90                   	nop
     aba:	90                   	nop
     abb:	90                   	nop
     abc:	90                   	nop
     abd:	90                   	nop
     abe:	90                   	nop
     abf:	90                   	nop

00000ac0 <atoi>:
  return r;
}

int
atoi(const char *s)
{
     ac0:	55                   	push   %ebp
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     ac1:	31 c0                	xor    %eax,%eax
  return r;
}

int
atoi(const char *s)
{
     ac3:	89 e5                	mov    %esp,%ebp
     ac5:	8b 4d 08             	mov    0x8(%ebp),%ecx
     ac8:	53                   	push   %ebx
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     ac9:	0f b6 11             	movzbl (%ecx),%edx
     acc:	8d 5a d0             	lea    -0x30(%edx),%ebx
     acf:	80 fb 09             	cmp    $0x9,%bl
     ad2:	77 1c                	ja     af0 <atoi+0x30>
     ad4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    n = n*10 + *s++ - '0';
     ad8:	0f be d2             	movsbl %dl,%edx
     adb:	83 c1 01             	add    $0x1,%ecx
     ade:	8d 04 80             	lea    (%eax,%eax,4),%eax
     ae1:	8d 44 42 d0          	lea    -0x30(%edx,%eax,2),%eax
atoi(const char *s)
{
  int n;

  n = 0;
  while('0' <= *s && *s <= '9')
     ae5:	0f b6 11             	movzbl (%ecx),%edx
     ae8:	8d 5a d0             	lea    -0x30(%edx),%ebx
     aeb:	80 fb 09             	cmp    $0x9,%bl
     aee:	76 e8                	jbe    ad8 <atoi+0x18>
    n = n*10 + *s++ - '0';
  return n;
}
     af0:	5b                   	pop    %ebx
     af1:	5d                   	pop    %ebp
     af2:	c3                   	ret    
     af3:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
     af9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000b00 <memmove>:

void*
memmove(void *vdst, void *vsrc, int n)
{
     b00:	55                   	push   %ebp
     b01:	89 e5                	mov    %esp,%ebp
     b03:	56                   	push   %esi
     b04:	8b 45 08             	mov    0x8(%ebp),%eax
     b07:	53                   	push   %ebx
     b08:	8b 5d 10             	mov    0x10(%ebp),%ebx
     b0b:	8b 75 0c             	mov    0xc(%ebp),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
     b0e:	85 db                	test   %ebx,%ebx
     b10:	7e 14                	jle    b26 <memmove+0x26>
    n = n*10 + *s++ - '0';
  return n;
}

void*
memmove(void *vdst, void *vsrc, int n)
     b12:	31 d2                	xor    %edx,%edx
     b14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
    *dst++ = *src++;
     b18:	0f b6 0c 16          	movzbl (%esi,%edx,1),%ecx
     b1c:	88 0c 10             	mov    %cl,(%eax,%edx,1)
     b1f:	83 c2 01             	add    $0x1,%edx
{
  char *dst, *src;
  
  dst = vdst;
  src = vsrc;
  while(n-- > 0)
     b22:	39 da                	cmp    %ebx,%edx
     b24:	75 f2                	jne    b18 <memmove+0x18>
    *dst++ = *src++;
  return vdst;
}
     b26:	5b                   	pop    %ebx
     b27:	5e                   	pop    %esi
     b28:	5d                   	pop    %ebp
     b29:	c3                   	ret    
     b2a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi

00000b30 <stat>:
  return buf;
}

int
stat(char *n, struct stat *st)
{
     b30:	55                   	push   %ebp
     b31:	89 e5                	mov    %esp,%ebp
     b33:	83 ec 18             	sub    $0x18,%esp
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     b36:	8b 45 08             	mov    0x8(%ebp),%eax
  return buf;
}

int
stat(char *n, struct stat *st)
{
     b39:	89 5d f8             	mov    %ebx,-0x8(%ebp)
     b3c:	89 75 fc             	mov    %esi,-0x4(%ebp)
  int fd;
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
     b3f:	be ff ff ff ff       	mov    $0xffffffff,%esi
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     b44:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
     b4b:	00 
     b4c:	89 04 24             	mov    %eax,(%esp)
     b4f:	e8 d4 00 00 00       	call   c28 <open>
  if(fd < 0)
     b54:	85 c0                	test   %eax,%eax
stat(char *n, struct stat *st)
{
  int fd;
  int r;

  fd = open(n, O_RDONLY);
     b56:	89 c3                	mov    %eax,%ebx
  if(fd < 0)
     b58:	78 19                	js     b73 <stat+0x43>
    return -1;
  r = fstat(fd, st);
     b5a:	8b 45 0c             	mov    0xc(%ebp),%eax
     b5d:	89 1c 24             	mov    %ebx,(%esp)
     b60:	89 44 24 04          	mov    %eax,0x4(%esp)
     b64:	e8 d7 00 00 00       	call   c40 <fstat>
  close(fd);
     b69:	89 1c 24             	mov    %ebx,(%esp)
  int r;

  fd = open(n, O_RDONLY);
  if(fd < 0)
    return -1;
  r = fstat(fd, st);
     b6c:	89 c6                	mov    %eax,%esi
  close(fd);
     b6e:	e8 9d 00 00 00       	call   c10 <close>
  return r;
}
     b73:	89 f0                	mov    %esi,%eax
     b75:	8b 5d f8             	mov    -0x8(%ebp),%ebx
     b78:	8b 75 fc             	mov    -0x4(%ebp),%esi
     b7b:	89 ec                	mov    %ebp,%esp
     b7d:	5d                   	pop    %ebp
     b7e:	c3                   	ret    
     b7f:	90                   	nop

00000b80 <gets>:
  return 0;
}

char*
gets(char *buf, int max)
{
     b80:	55                   	push   %ebp
     b81:	89 e5                	mov    %esp,%ebp
     b83:	57                   	push   %edi
     b84:	56                   	push   %esi
     b85:	31 f6                	xor    %esi,%esi
     b87:	53                   	push   %ebx
     b88:	83 ec 2c             	sub    $0x2c,%esp
     b8b:	8b 7d 08             	mov    0x8(%ebp),%edi
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     b8e:	eb 06                	jmp    b96 <gets+0x16>
    cc = read(0, &c, 1);
    if(cc < 1)
      break;
    buf[i++] = c;
    if(c == '\n' || c == '\r')
     b90:	3c 0a                	cmp    $0xa,%al
     b92:	74 39                	je     bcd <gets+0x4d>
     b94:	89 de                	mov    %ebx,%esi
gets(char *buf, int max)
{
  int i, cc;
  char c;

  for(i=0; i+1 < max; ){
     b96:	8d 5e 01             	lea    0x1(%esi),%ebx
     b99:	3b 5d 0c             	cmp    0xc(%ebp),%ebx
     b9c:	7d 31                	jge    bcf <gets+0x4f>
    cc = read(0, &c, 1);
     b9e:	8d 45 e7             	lea    -0x19(%ebp),%eax
     ba1:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     ba8:	00 
     ba9:	89 44 24 04          	mov    %eax,0x4(%esp)
     bad:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
     bb4:	e8 47 00 00 00       	call   c00 <read>
    if(cc < 1)
     bb9:	85 c0                	test   %eax,%eax
     bbb:	7e 12                	jle    bcf <gets+0x4f>
      break;
    buf[i++] = c;
     bbd:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
     bc1:	88 44 1f ff          	mov    %al,-0x1(%edi,%ebx,1)
    if(c == '\n' || c == '\r')
     bc5:	0f b6 45 e7          	movzbl -0x19(%ebp),%eax
     bc9:	3c 0d                	cmp    $0xd,%al
     bcb:	75 c3                	jne    b90 <gets+0x10>
     bcd:	89 de                	mov    %ebx,%esi
      break;
  }
  buf[i] = '\0';
     bcf:	c6 04 37 00          	movb   $0x0,(%edi,%esi,1)
  return buf;
}
     bd3:	89 f8                	mov    %edi,%eax
     bd5:	83 c4 2c             	add    $0x2c,%esp
     bd8:	5b                   	pop    %ebx
     bd9:	5e                   	pop    %esi
     bda:	5f                   	pop    %edi
     bdb:	5d                   	pop    %ebp
     bdc:	c3                   	ret    
     bdd:	90                   	nop
     bde:	90                   	nop
     bdf:	90                   	nop

00000be0 <fork>:
  name: \
    movl $SYS_ ## name, %eax; \
    int $T_SYSCALL; \
    ret

SYSCALL(fork)
     be0:	b8 01 00 00 00       	mov    $0x1,%eax
     be5:	cd 40                	int    $0x40
     be7:	c3                   	ret    

00000be8 <exit>:
SYSCALL(exit)
     be8:	b8 02 00 00 00       	mov    $0x2,%eax
     bed:	cd 40                	int    $0x40
     bef:	c3                   	ret    

00000bf0 <wait>:
SYSCALL(wait)
     bf0:	b8 03 00 00 00       	mov    $0x3,%eax
     bf5:	cd 40                	int    $0x40
     bf7:	c3                   	ret    

00000bf8 <pipe>:
SYSCALL(pipe)
     bf8:	b8 04 00 00 00       	mov    $0x4,%eax
     bfd:	cd 40                	int    $0x40
     bff:	c3                   	ret    

00000c00 <read>:
SYSCALL(read)
     c00:	b8 06 00 00 00       	mov    $0x6,%eax
     c05:	cd 40                	int    $0x40
     c07:	c3                   	ret    

00000c08 <write>:
SYSCALL(write)
     c08:	b8 05 00 00 00       	mov    $0x5,%eax
     c0d:	cd 40                	int    $0x40
     c0f:	c3                   	ret    

00000c10 <close>:
SYSCALL(close)
     c10:	b8 07 00 00 00       	mov    $0x7,%eax
     c15:	cd 40                	int    $0x40
     c17:	c3                   	ret    

00000c18 <kill>:
SYSCALL(kill)
     c18:	b8 08 00 00 00       	mov    $0x8,%eax
     c1d:	cd 40                	int    $0x40
     c1f:	c3                   	ret    

00000c20 <exec>:
SYSCALL(exec)
     c20:	b8 09 00 00 00       	mov    $0x9,%eax
     c25:	cd 40                	int    $0x40
     c27:	c3                   	ret    

00000c28 <open>:
SYSCALL(open)
     c28:	b8 0a 00 00 00       	mov    $0xa,%eax
     c2d:	cd 40                	int    $0x40
     c2f:	c3                   	ret    

00000c30 <mknod>:
SYSCALL(mknod)
     c30:	b8 0b 00 00 00       	mov    $0xb,%eax
     c35:	cd 40                	int    $0x40
     c37:	c3                   	ret    

00000c38 <unlink>:
SYSCALL(unlink)
     c38:	b8 0c 00 00 00       	mov    $0xc,%eax
     c3d:	cd 40                	int    $0x40
     c3f:	c3                   	ret    

00000c40 <fstat>:
SYSCALL(fstat)
     c40:	b8 0d 00 00 00       	mov    $0xd,%eax
     c45:	cd 40                	int    $0x40
     c47:	c3                   	ret    

00000c48 <link>:
SYSCALL(link)
     c48:	b8 0e 00 00 00       	mov    $0xe,%eax
     c4d:	cd 40                	int    $0x40
     c4f:	c3                   	ret    

00000c50 <mkdir>:
SYSCALL(mkdir)
     c50:	b8 0f 00 00 00       	mov    $0xf,%eax
     c55:	cd 40                	int    $0x40
     c57:	c3                   	ret    

00000c58 <chdir>:
SYSCALL(chdir)
     c58:	b8 10 00 00 00       	mov    $0x10,%eax
     c5d:	cd 40                	int    $0x40
     c5f:	c3                   	ret    

00000c60 <dup>:
SYSCALL(dup)
     c60:	b8 11 00 00 00       	mov    $0x11,%eax
     c65:	cd 40                	int    $0x40
     c67:	c3                   	ret    

00000c68 <getpid>:
SYSCALL(getpid)
     c68:	b8 12 00 00 00       	mov    $0x12,%eax
     c6d:	cd 40                	int    $0x40
     c6f:	c3                   	ret    

00000c70 <sbrk>:
SYSCALL(sbrk)
     c70:	b8 13 00 00 00       	mov    $0x13,%eax
     c75:	cd 40                	int    $0x40
     c77:	c3                   	ret    

00000c78 <sleep>:
SYSCALL(sleep)
     c78:	b8 14 00 00 00       	mov    $0x14,%eax
     c7d:	cd 40                	int    $0x40
     c7f:	c3                   	ret    

00000c80 <uptime>:
SYSCALL(uptime)
     c80:	b8 15 00 00 00       	mov    $0x15,%eax
     c85:	cd 40                	int    $0x40
     c87:	c3                   	ret    

00000c88 <thread_create>:
SYSCALL(thread_create)
     c88:	b8 16 00 00 00       	mov    $0x16,%eax
     c8d:	cd 40                	int    $0x40
     c8f:	c3                   	ret    

00000c90 <thread_getid>:
SYSCALL(thread_getid)
     c90:	b8 17 00 00 00       	mov    $0x17,%eax
     c95:	cd 40                	int    $0x40
     c97:	c3                   	ret    

00000c98 <thread_getProcid>:
SYSCALL(thread_getProcid)
     c98:	b8 18 00 00 00       	mov    $0x18,%eax
     c9d:	cd 40                	int    $0x40
     c9f:	c3                   	ret    

00000ca0 <thread_exit>:
SYSCALL(thread_exit)
     ca0:	b8 1a 00 00 00       	mov    $0x1a,%eax
     ca5:	cd 40                	int    $0x40
     ca7:	c3                   	ret    

00000ca8 <thread_join>:
SYSCALL(thread_join)
     ca8:	b8 19 00 00 00       	mov    $0x19,%eax
     cad:	cd 40                	int    $0x40
     caf:	c3                   	ret    

00000cb0 <binary_sem_create>:
SYSCALL(binary_sem_create)
     cb0:	b8 1b 00 00 00       	mov    $0x1b,%eax
     cb5:	cd 40                	int    $0x40
     cb7:	c3                   	ret    

00000cb8 <binary_sem_down>:
SYSCALL(binary_sem_down)
     cb8:	b8 1c 00 00 00       	mov    $0x1c,%eax
     cbd:	cd 40                	int    $0x40
     cbf:	c3                   	ret    

00000cc0 <binary_sem_up>:
SYSCALL(binary_sem_up)
     cc0:	b8 1d 00 00 00       	mov    $0x1d,%eax
     cc5:	cd 40                	int    $0x40
     cc7:	c3                   	ret    

00000cc8 <binary_sem_clear>:
SYSCALL(binary_sem_clear)
     cc8:	b8 1e 00 00 00       	mov    $0x1e,%eax
     ccd:	cd 40                	int    $0x40
     ccf:	c3                   	ret    

00000cd0 <exit_all_threads>:
     cd0:	b8 1f 00 00 00       	mov    $0x1f,%eax
     cd5:	cd 40                	int    $0x40
     cd7:	c3                   	ret    
     cd8:	90                   	nop
     cd9:	90                   	nop
     cda:	90                   	nop
     cdb:	90                   	nop
     cdc:	90                   	nop
     cdd:	90                   	nop
     cde:	90                   	nop
     cdf:	90                   	nop

00000ce0 <printint>:
	write(fd, &c, 1);
}

static void
printint(int fd, int xx, int base, int sgn)
{
     ce0:	55                   	push   %ebp
     ce1:	89 e5                	mov    %esp,%ebp
     ce3:	57                   	push   %edi
     ce4:	89 cf                	mov    %ecx,%edi
     ce6:	56                   	push   %esi
     ce7:	89 c6                	mov    %eax,%esi
     ce9:	53                   	push   %ebx
     cea:	83 ec 4c             	sub    $0x4c,%esp
	char buf[16];
	int i, neg;
	uint x;

	neg = 0;
	if(sgn && xx < 0){
     ced:	8b 4d 08             	mov    0x8(%ebp),%ecx
     cf0:	85 c9                	test   %ecx,%ecx
     cf2:	74 04                	je     cf8 <printint+0x18>
     cf4:	85 d2                	test   %edx,%edx
     cf6:	78 70                	js     d68 <printint+0x88>
		neg = 1;
		x = -xx;
	} else {
		x = xx;
     cf8:	89 d0                	mov    %edx,%eax
     cfa:	c7 45 c4 00 00 00 00 	movl   $0x0,-0x3c(%ebp)
     d01:	31 c9                	xor    %ecx,%ecx
     d03:	8d 5d d7             	lea    -0x29(%ebp),%ebx
     d06:	66 90                	xchg   %ax,%ax
	}

	i = 0;
	do{
		buf[i++] = digits[x % base];
     d08:	31 d2                	xor    %edx,%edx
     d0a:	f7 f7                	div    %edi
     d0c:	0f b6 92 9f 16 00 00 	movzbl 0x169f(%edx),%edx
     d13:	88 14 0b             	mov    %dl,(%ebx,%ecx,1)
     d16:	83 c1 01             	add    $0x1,%ecx
	}while((x /= base) != 0);
     d19:	85 c0                	test   %eax,%eax
     d1b:	75 eb                	jne    d08 <printint+0x28>
	if(neg)
     d1d:	8b 45 c4             	mov    -0x3c(%ebp),%eax
     d20:	85 c0                	test   %eax,%eax
     d22:	74 08                	je     d2c <printint+0x4c>
		buf[i++] = '-';
     d24:	c6 44 0d d7 2d       	movb   $0x2d,-0x29(%ebp,%ecx,1)
     d29:	83 c1 01             	add    $0x1,%ecx

	while(--i >= 0)
     d2c:	8d 79 ff             	lea    -0x1(%ecx),%edi
     d2f:	01 fb                	add    %edi,%ebx
     d31:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
     d38:	0f b6 03             	movzbl (%ebx),%eax
     d3b:	83 ef 01             	sub    $0x1,%edi
     d3e:	83 eb 01             	sub    $0x1,%ebx
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     d41:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     d48:	00 
     d49:	89 34 24             	mov    %esi,(%esp)
		buf[i++] = digits[x % base];
	}while((x /= base) != 0);
	if(neg)
		buf[i++] = '-';

	while(--i >= 0)
     d4c:	88 45 e7             	mov    %al,-0x19(%ebp)
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     d4f:	8d 45 e7             	lea    -0x19(%ebp),%eax
     d52:	89 44 24 04          	mov    %eax,0x4(%esp)
     d56:	e8 ad fe ff ff       	call   c08 <write>
		buf[i++] = digits[x % base];
	}while((x /= base) != 0);
	if(neg)
		buf[i++] = '-';

	while(--i >= 0)
     d5b:	83 ff ff             	cmp    $0xffffffff,%edi
     d5e:	75 d8                	jne    d38 <printint+0x58>
		putc(fd, buf[i]);
}
     d60:	83 c4 4c             	add    $0x4c,%esp
     d63:	5b                   	pop    %ebx
     d64:	5e                   	pop    %esi
     d65:	5f                   	pop    %edi
     d66:	5d                   	pop    %ebp
     d67:	c3                   	ret    
	uint x;

	neg = 0;
	if(sgn && xx < 0){
		neg = 1;
		x = -xx;
     d68:	89 d0                	mov    %edx,%eax
     d6a:	f7 d8                	neg    %eax
     d6c:	c7 45 c4 01 00 00 00 	movl   $0x1,-0x3c(%ebp)
     d73:	eb 8c                	jmp    d01 <printint+0x21>
     d75:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     d79:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00000d80 <printf>:
}

// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
     d80:	55                   	push   %ebp
     d81:	89 e5                	mov    %esp,%ebp
     d83:	57                   	push   %edi
     d84:	56                   	push   %esi
     d85:	53                   	push   %ebx
     d86:	83 ec 3c             	sub    $0x3c,%esp
	int c, i, state;
	uint *ap;

	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
     d89:	8b 45 0c             	mov    0xc(%ebp),%eax
     d8c:	0f b6 10             	movzbl (%eax),%edx
     d8f:	84 d2                	test   %dl,%dl
     d91:	0f 84 c9 00 00 00    	je     e60 <printf+0xe0>
	char *s;
	int c, i, state;
	uint *ap;

	state = 0;
	ap = (uint*)(void*)&fmt + 1;
     d97:	8d 4d 10             	lea    0x10(%ebp),%ecx
     d9a:	31 ff                	xor    %edi,%edi
     d9c:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
     d9f:	31 db                	xor    %ebx,%ebx
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     da1:	8d 75 e7             	lea    -0x19(%ebp),%esi
     da4:	eb 1e                	jmp    dc4 <printf+0x44>
     da6:	66 90                	xchg   %ax,%ax
	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
		c = fmt[i] & 0xff;
		if(state == 0){
			if(c == '%'){
     da8:	83 fa 25             	cmp    $0x25,%edx
     dab:	0f 85 b7 00 00 00    	jne    e68 <printf+0xe8>
     db1:	66 bf 25 00          	mov    $0x25,%di
	int c, i, state;
	uint *ap;

	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
     db5:	83 c3 01             	add    $0x1,%ebx
     db8:	0f b6 14 18          	movzbl (%eax,%ebx,1),%edx
     dbc:	84 d2                	test   %dl,%dl
     dbe:	0f 84 9c 00 00 00    	je     e60 <printf+0xe0>
		c = fmt[i] & 0xff;
		if(state == 0){
     dc4:	85 ff                	test   %edi,%edi
	uint *ap;

	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
		c = fmt[i] & 0xff;
     dc6:	0f b6 d2             	movzbl %dl,%edx
		if(state == 0){
     dc9:	74 dd                	je     da8 <printf+0x28>
			if(c == '%'){
				state = '%';
			} else {
				putc(fd, c);
			}
		} else if(state == '%'){
     dcb:	83 ff 25             	cmp    $0x25,%edi
     dce:	75 e5                	jne    db5 <printf+0x35>
			if(c == 'd'){
     dd0:	83 fa 64             	cmp    $0x64,%edx
     dd3:	0f 84 57 01 00 00    	je     f30 <printf+0x1b0>
				printint(fd, *ap, 10, 1);
				ap++;
			} else if(c == 'x' || c == 'p'){
     dd9:	83 fa 70             	cmp    $0x70,%edx
     ddc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     de0:	0f 84 aa 00 00 00    	je     e90 <printf+0x110>
     de6:	83 fa 78             	cmp    $0x78,%edx
     de9:	0f 84 a1 00 00 00    	je     e90 <printf+0x110>
				printint(fd, *ap, 16, 0);
				ap++;
			} else if(c == 's'){
     def:	83 fa 73             	cmp    $0x73,%edx
     df2:	0f 84 c0 00 00 00    	je     eb8 <printf+0x138>
					s = "(null)";
				while(*s != 0){
					putc(fd, *s);
					s++;
				}
			} else if(c == 'c'){
     df8:	83 fa 63             	cmp    $0x63,%edx
     dfb:	90                   	nop
     dfc:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
     e00:	0f 84 52 01 00 00    	je     f58 <printf+0x1d8>
				putc(fd, *ap);
				ap++;
			} else if(c == '%'){
     e06:	83 fa 25             	cmp    $0x25,%edx
     e09:	0f 84 f9 00 00 00    	je     f08 <printf+0x188>
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     e0f:	8b 4d 08             	mov    0x8(%ebp),%ecx
	int c, i, state;
	uint *ap;

	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
     e12:	83 c3 01             	add    $0x1,%ebx
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     e15:	31 ff                	xor    %edi,%edi
     e17:	89 55 cc             	mov    %edx,-0x34(%ebp)
     e1a:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
     e1e:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     e25:	00 
     e26:	89 0c 24             	mov    %ecx,(%esp)
     e29:	89 74 24 04          	mov    %esi,0x4(%esp)
     e2d:	e8 d6 fd ff ff       	call   c08 <write>
     e32:	8b 55 cc             	mov    -0x34(%ebp),%edx
     e35:	8b 45 08             	mov    0x8(%ebp),%eax
     e38:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     e3f:	00 
     e40:	89 74 24 04          	mov    %esi,0x4(%esp)
     e44:	88 55 e7             	mov    %dl,-0x19(%ebp)
     e47:	89 04 24             	mov    %eax,(%esp)
     e4a:	e8 b9 fd ff ff       	call   c08 <write>
     e4f:	8b 45 0c             	mov    0xc(%ebp),%eax
	int c, i, state;
	uint *ap;

	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
     e52:	0f b6 14 18          	movzbl (%eax,%ebx,1),%edx
     e56:	84 d2                	test   %dl,%dl
     e58:	0f 85 66 ff ff ff    	jne    dc4 <printf+0x44>
     e5e:	66 90                	xchg   %ax,%ax
				putc(fd, c);
			}
			state = 0;
		}
	}
}
     e60:	83 c4 3c             	add    $0x3c,%esp
     e63:	5b                   	pop    %ebx
     e64:	5e                   	pop    %esi
     e65:	5f                   	pop    %edi
     e66:	5d                   	pop    %ebp
     e67:	c3                   	ret    
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     e68:	8b 45 08             	mov    0x8(%ebp),%eax
	state = 0;
	ap = (uint*)(void*)&fmt + 1;
	for(i = 0; fmt[i]; i++){
		c = fmt[i] & 0xff;
		if(state == 0){
			if(c == '%'){
     e6b:	88 55 e7             	mov    %dl,-0x19(%ebp)
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     e6e:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     e75:	00 
     e76:	89 74 24 04          	mov    %esi,0x4(%esp)
     e7a:	89 04 24             	mov    %eax,(%esp)
     e7d:	e8 86 fd ff ff       	call   c08 <write>
     e82:	8b 45 0c             	mov    0xc(%ebp),%eax
     e85:	e9 2b ff ff ff       	jmp    db5 <printf+0x35>
     e8a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
		} else if(state == '%'){
			if(c == 'd'){
				printint(fd, *ap, 10, 1);
				ap++;
			} else if(c == 'x' || c == 'p'){
				printint(fd, *ap, 16, 0);
     e90:	8b 45 d4             	mov    -0x2c(%ebp),%eax
     e93:	b9 10 00 00 00       	mov    $0x10,%ecx
				ap++;
     e98:	31 ff                	xor    %edi,%edi
		} else if(state == '%'){
			if(c == 'd'){
				printint(fd, *ap, 10, 1);
				ap++;
			} else if(c == 'x' || c == 'p'){
				printint(fd, *ap, 16, 0);
     e9a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
     ea1:	8b 10                	mov    (%eax),%edx
     ea3:	8b 45 08             	mov    0x8(%ebp),%eax
     ea6:	e8 35 fe ff ff       	call   ce0 <printint>
     eab:	8b 45 0c             	mov    0xc(%ebp),%eax
				ap++;
     eae:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
     eb2:	e9 fe fe ff ff       	jmp    db5 <printf+0x35>
     eb7:	90                   	nop
			} else if(c == 's'){
				s = (char*)*ap;
     eb8:	8b 55 d4             	mov    -0x2c(%ebp),%edx
     ebb:	8b 3a                	mov    (%edx),%edi
				ap++;
     ebd:	83 c2 04             	add    $0x4,%edx
     ec0:	89 55 d4             	mov    %edx,-0x2c(%ebp)
				if(s == 0)
     ec3:	85 ff                	test   %edi,%edi
     ec5:	0f 84 ba 00 00 00    	je     f85 <printf+0x205>
					s = "(null)";
				while(*s != 0){
     ecb:	0f b6 17             	movzbl (%edi),%edx
     ece:	84 d2                	test   %dl,%dl
     ed0:	74 2d                	je     eff <printf+0x17f>
     ed2:	89 5d d0             	mov    %ebx,-0x30(%ebp)
     ed5:	8b 5d 08             	mov    0x8(%ebp),%ebx
					putc(fd, *s);
					s++;
     ed8:	83 c7 01             	add    $0x1,%edi
			} else if(c == 's'){
				s = (char*)*ap;
				ap++;
				if(s == 0)
					s = "(null)";
				while(*s != 0){
     edb:	88 55 e7             	mov    %dl,-0x19(%ebp)
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     ede:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     ee5:	00 
     ee6:	89 74 24 04          	mov    %esi,0x4(%esp)
     eea:	89 1c 24             	mov    %ebx,(%esp)
     eed:	e8 16 fd ff ff       	call   c08 <write>
			} else if(c == 's'){
				s = (char*)*ap;
				ap++;
				if(s == 0)
					s = "(null)";
				while(*s != 0){
     ef2:	0f b6 17             	movzbl (%edi),%edx
     ef5:	84 d2                	test   %dl,%dl
     ef7:	75 df                	jne    ed8 <printf+0x158>
     ef9:	8b 5d d0             	mov    -0x30(%ebp),%ebx
     efc:	8b 45 0c             	mov    0xc(%ebp),%eax
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     eff:	31 ff                	xor    %edi,%edi
     f01:	e9 af fe ff ff       	jmp    db5 <printf+0x35>
     f06:	66 90                	xchg   %ax,%ax
     f08:	8b 55 08             	mov    0x8(%ebp),%edx
     f0b:	31 ff                	xor    %edi,%edi
					s++;
				}
			} else if(c == 'c'){
				putc(fd, *ap);
				ap++;
			} else if(c == '%'){
     f0d:	c6 45 e7 25          	movb   $0x25,-0x19(%ebp)
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     f11:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     f18:	00 
     f19:	89 74 24 04          	mov    %esi,0x4(%esp)
     f1d:	89 14 24             	mov    %edx,(%esp)
     f20:	e8 e3 fc ff ff       	call   c08 <write>
     f25:	8b 45 0c             	mov    0xc(%ebp),%eax
     f28:	e9 88 fe ff ff       	jmp    db5 <printf+0x35>
     f2d:	8d 76 00             	lea    0x0(%esi),%esi
			} else {
				putc(fd, c);
			}
		} else if(state == '%'){
			if(c == 'd'){
				printint(fd, *ap, 10, 1);
     f30:	8b 45 d4             	mov    -0x2c(%ebp),%eax
     f33:	b9 0a 00 00 00       	mov    $0xa,%ecx
				ap++;
     f38:	66 31 ff             	xor    %di,%di
			} else {
				putc(fd, c);
			}
		} else if(state == '%'){
			if(c == 'd'){
				printint(fd, *ap, 10, 1);
     f3b:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
     f42:	8b 10                	mov    (%eax),%edx
     f44:	8b 45 08             	mov    0x8(%ebp),%eax
     f47:	e8 94 fd ff ff       	call   ce0 <printint>
     f4c:	8b 45 0c             	mov    0xc(%ebp),%eax
				ap++;
     f4f:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
     f53:	e9 5d fe ff ff       	jmp    db5 <printf+0x35>
					s = "(null)";
				while(*s != 0){
					putc(fd, *s);
					s++;
				}
			} else if(c == 'c'){
     f58:	8b 4d d4             	mov    -0x2c(%ebp),%ecx
				putc(fd, *ap);
				ap++;
     f5b:	31 ff                	xor    %edi,%edi
					s = "(null)";
				while(*s != 0){
					putc(fd, *s);
					s++;
				}
			} else if(c == 'c'){
     f5d:	8b 01                	mov    (%ecx),%eax
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     f5f:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
     f66:	00 
     f67:	89 74 24 04          	mov    %esi,0x4(%esp)
					s = "(null)";
				while(*s != 0){
					putc(fd, *s);
					s++;
				}
			} else if(c == 'c'){
     f6b:	88 45 e7             	mov    %al,-0x19(%ebp)
int binsem_sync_print;

static void
putc(int fd, char c)
{
	write(fd, &c, 1);
     f6e:	8b 45 08             	mov    0x8(%ebp),%eax
     f71:	89 04 24             	mov    %eax,(%esp)
     f74:	e8 8f fc ff ff       	call   c08 <write>
     f79:	8b 45 0c             	mov    0xc(%ebp),%eax
					putc(fd, *s);
					s++;
				}
			} else if(c == 'c'){
				putc(fd, *ap);
				ap++;
     f7c:	83 45 d4 04          	addl   $0x4,-0x2c(%ebp)
     f80:	e9 30 fe ff ff       	jmp    db5 <printf+0x35>
				printint(fd, *ap, 16, 0);
				ap++;
			} else if(c == 's'){
				s = (char*)*ap;
				ap++;
				if(s == 0)
     f85:	bf 98 16 00 00       	mov    $0x1698,%edi
     f8a:	e9 3c ff ff ff       	jmp    ecb <printf+0x14b>
     f8f:	90                   	nop

00000f90 <free>:
static Header base;
static Header *freep;

void
free(void *ap)
{
     f90:	55                   	push   %ebp
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
     f91:	a1 68 17 00 00       	mov    0x1768,%eax
static Header base;
static Header *freep;

void
free(void *ap)
{
     f96:	89 e5                	mov    %esp,%ebp
     f98:	57                   	push   %edi
     f99:	56                   	push   %esi
     f9a:	53                   	push   %ebx
     f9b:	8b 5d 08             	mov    0x8(%ebp),%ebx
  Header *bp, *p;

  bp = (Header*) ap - 1;
     f9e:	8d 4b f8             	lea    -0x8(%ebx),%ecx
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
     fa1:	39 c8                	cmp    %ecx,%eax
     fa3:	73 1d                	jae    fc2 <free+0x32>
     fa5:	8d 76 00             	lea    0x0(%esi),%esi
     fa8:	8b 10                	mov    (%eax),%edx
     faa:	39 d1                	cmp    %edx,%ecx
     fac:	72 1a                	jb     fc8 <free+0x38>
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
     fae:	39 d0                	cmp    %edx,%eax
     fb0:	72 08                	jb     fba <free+0x2a>
     fb2:	39 c8                	cmp    %ecx,%eax
     fb4:	72 12                	jb     fc8 <free+0x38>
     fb6:	39 d1                	cmp    %edx,%ecx
     fb8:	72 0e                	jb     fc8 <free+0x38>
     fba:	89 d0                	mov    %edx,%eax
free(void *ap)
{
  Header *bp, *p;

  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
     fbc:	39 c8                	cmp    %ecx,%eax
     fbe:	66 90                	xchg   %ax,%ax
     fc0:	72 e6                	jb     fa8 <free+0x18>
     fc2:	8b 10                	mov    (%eax),%edx
     fc4:	eb e8                	jmp    fae <free+0x1e>
     fc6:	66 90                	xchg   %ax,%ax
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
     fc8:	8b 71 04             	mov    0x4(%ecx),%esi
     fcb:	8d 3c f1             	lea    (%ecx,%esi,8),%edi
     fce:	39 d7                	cmp    %edx,%edi
     fd0:	74 19                	je     feb <free+0x5b>
    bp->s.size += p->s.ptr->s.size;
    bp->s.ptr = p->s.ptr->s.ptr;
  } else
    bp->s.ptr = p->s.ptr;
     fd2:	89 53 f8             	mov    %edx,-0x8(%ebx)
  if(p + p->s.size == bp){
     fd5:	8b 50 04             	mov    0x4(%eax),%edx
     fd8:	8d 34 d0             	lea    (%eax,%edx,8),%esi
     fdb:	39 ce                	cmp    %ecx,%esi
     fdd:	74 23                	je     1002 <free+0x72>
    p->s.size += bp->s.size;
    p->s.ptr = bp->s.ptr;
  } else
    p->s.ptr = bp;
     fdf:	89 08                	mov    %ecx,(%eax)
  freep = p;
     fe1:	a3 68 17 00 00       	mov    %eax,0x1768
}
     fe6:	5b                   	pop    %ebx
     fe7:	5e                   	pop    %esi
     fe8:	5f                   	pop    %edi
     fe9:	5d                   	pop    %ebp
     fea:	c3                   	ret    
  bp = (Header*) ap - 1;
  for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
    if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
      break;
  if(bp + bp->s.size == p->s.ptr){
    bp->s.size += p->s.ptr->s.size;
     feb:	03 72 04             	add    0x4(%edx),%esi
     fee:	89 71 04             	mov    %esi,0x4(%ecx)
    bp->s.ptr = p->s.ptr->s.ptr;
     ff1:	8b 10                	mov    (%eax),%edx
     ff3:	8b 12                	mov    (%edx),%edx
     ff5:	89 53 f8             	mov    %edx,-0x8(%ebx)
  } else
    bp->s.ptr = p->s.ptr;
  if(p + p->s.size == bp){
     ff8:	8b 50 04             	mov    0x4(%eax),%edx
     ffb:	8d 34 d0             	lea    (%eax,%edx,8),%esi
     ffe:	39 ce                	cmp    %ecx,%esi
    1000:	75 dd                	jne    fdf <free+0x4f>
    p->s.size += bp->s.size;
    1002:	03 51 04             	add    0x4(%ecx),%edx
    1005:	89 50 04             	mov    %edx,0x4(%eax)
    p->s.ptr = bp->s.ptr;
    1008:	8b 53 f8             	mov    -0x8(%ebx),%edx
    100b:	89 10                	mov    %edx,(%eax)
  } else
    p->s.ptr = bp;
  freep = p;
    100d:	a3 68 17 00 00       	mov    %eax,0x1768
}
    1012:	5b                   	pop    %ebx
    1013:	5e                   	pop    %esi
    1014:	5f                   	pop    %edi
    1015:	5d                   	pop    %ebp
    1016:	c3                   	ret    
    1017:	89 f6                	mov    %esi,%esi
    1019:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00001020 <malloc>:
  return freep;
}

void*
malloc(uint nbytes)
{
    1020:	55                   	push   %ebp
    1021:	89 e5                	mov    %esp,%ebp
    1023:	57                   	push   %edi
    1024:	56                   	push   %esi
    1025:	53                   	push   %ebx
    1026:	83 ec 1c             	sub    $0x1c,%esp
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
    1029:	8b 5d 08             	mov    0x8(%ebp),%ebx
  if((prevp = freep) == 0){
    102c:	8b 0d 68 17 00 00    	mov    0x1768,%ecx
malloc(uint nbytes)
{
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
    1032:	83 c3 07             	add    $0x7,%ebx
    1035:	c1 eb 03             	shr    $0x3,%ebx
    1038:	83 c3 01             	add    $0x1,%ebx
  if((prevp = freep) == 0){
    103b:	85 c9                	test   %ecx,%ecx
    103d:	0f 84 93 00 00 00    	je     10d6 <malloc+0xb6>
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    1043:	8b 01                	mov    (%ecx),%eax
    if(p->s.size >= nunits){
    1045:	8b 50 04             	mov    0x4(%eax),%edx
    1048:	39 d3                	cmp    %edx,%ebx
    104a:	76 1f                	jbe    106b <malloc+0x4b>
        p->s.size -= nunits;
        p += p->s.size;
        p->s.size = nunits;
      }
      freep = prevp;
      return (void*) (p + 1);
    104c:	8d 34 dd 00 00 00 00 	lea    0x0(,%ebx,8),%esi
    1053:	90                   	nop
    1054:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
    }
    if(p == freep)
    1058:	3b 05 68 17 00 00    	cmp    0x1768,%eax
    105e:	74 30                	je     1090 <malloc+0x70>
    1060:	89 c1                	mov    %eax,%ecx
  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    1062:	8b 01                	mov    (%ecx),%eax
    if(p->s.size >= nunits){
    1064:	8b 50 04             	mov    0x4(%eax),%edx
    1067:	39 d3                	cmp    %edx,%ebx
    1069:	77 ed                	ja     1058 <malloc+0x38>
      if(p->s.size == nunits)
    106b:	39 d3                	cmp    %edx,%ebx
    106d:	74 61                	je     10d0 <malloc+0xb0>
        prevp->s.ptr = p->s.ptr;
      else {
        p->s.size -= nunits;
    106f:	29 da                	sub    %ebx,%edx
    1071:	89 50 04             	mov    %edx,0x4(%eax)
        p += p->s.size;
    1074:	8d 04 d0             	lea    (%eax,%edx,8),%eax
        p->s.size = nunits;
    1077:	89 58 04             	mov    %ebx,0x4(%eax)
      }
      freep = prevp;
    107a:	89 0d 68 17 00 00    	mov    %ecx,0x1768
      return (void*) (p + 1);
    1080:	83 c0 08             	add    $0x8,%eax
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
        return 0;
  }
}
    1083:	83 c4 1c             	add    $0x1c,%esp
    1086:	5b                   	pop    %ebx
    1087:	5e                   	pop    %esi
    1088:	5f                   	pop    %edi
    1089:	5d                   	pop    %ebp
    108a:	c3                   	ret    
    108b:	90                   	nop
    108c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
morecore(uint nu)
{
  char *p;
  Header *hp;

  if(nu < 4096)
    1090:	81 fb ff 0f 00 00    	cmp    $0xfff,%ebx
    1096:	b8 00 80 00 00       	mov    $0x8000,%eax
    109b:	bf 00 10 00 00       	mov    $0x1000,%edi
    10a0:	76 04                	jbe    10a6 <malloc+0x86>
    10a2:	89 f0                	mov    %esi,%eax
    10a4:	89 df                	mov    %ebx,%edi
    nu = 4096;
  p = sbrk(nu * sizeof(Header));
    10a6:	89 04 24             	mov    %eax,(%esp)
    10a9:	e8 c2 fb ff ff       	call   c70 <sbrk>
  if(p == (char*) -1)
    10ae:	83 f8 ff             	cmp    $0xffffffff,%eax
    10b1:	74 18                	je     10cb <malloc+0xab>
    return 0;
  hp = (Header*)p;
  hp->s.size = nu;
    10b3:	89 78 04             	mov    %edi,0x4(%eax)
  free((void*)(hp + 1));
    10b6:	83 c0 08             	add    $0x8,%eax
    10b9:	89 04 24             	mov    %eax,(%esp)
    10bc:	e8 cf fe ff ff       	call   f90 <free>
  return freep;
    10c1:	8b 0d 68 17 00 00    	mov    0x1768,%ecx
      }
      freep = prevp;
      return (void*) (p + 1);
    }
    if(p == freep)
      if((p = morecore(nunits)) == 0)
    10c7:	85 c9                	test   %ecx,%ecx
    10c9:	75 97                	jne    1062 <malloc+0x42>
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    base.s.size = 0;
  }
  for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
    if(p->s.size >= nunits){
    10cb:	31 c0                	xor    %eax,%eax
    10cd:	eb b4                	jmp    1083 <malloc+0x63>
    10cf:	90                   	nop
      if(p->s.size == nunits)
        prevp->s.ptr = p->s.ptr;
    10d0:	8b 10                	mov    (%eax),%edx
    10d2:	89 11                	mov    %edx,(%ecx)
    10d4:	eb a4                	jmp    107a <malloc+0x5a>
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    10d6:	c7 05 68 17 00 00 60 	movl   $0x1760,0x1768
    10dd:	17 00 00 
    base.s.size = 0;
    10e0:	b9 60 17 00 00       	mov    $0x1760,%ecx
  Header *p, *prevp;
  uint nunits;

  nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
  if((prevp = freep) == 0){
    base.s.ptr = freep = prevp = &base;
    10e5:	c7 05 60 17 00 00 60 	movl   $0x1760,0x1760
    10ec:	17 00 00 
    base.s.size = 0;
    10ef:	c7 05 64 17 00 00 00 	movl   $0x0,0x1764
    10f6:	00 00 00 
    10f9:	e9 45 ff ff ff       	jmp    1043 <malloc+0x23>
    10fe:	90                   	nop
    10ff:	90                   	nop

00001100 <sem_clear>:
	}
	binary_sem_up(sem->S1);
}

void sem_clear(struct semaphore* sem )
{
    1100:	55                   	push   %ebp
    1101:	89 e5                	mov    %esp,%ebp
    1103:	53                   	push   %ebx
    1104:	83 ec 14             	sub    $0x14,%esp
    1107:	8b 5d 08             	mov    0x8(%ebp),%ebx
	binary_sem_clear(sem->S1);
    110a:	8b 03                	mov    (%ebx),%eax
    110c:	89 04 24             	mov    %eax,(%esp)
    110f:	e8 b4 fb ff ff       	call   cc8 <binary_sem_clear>
	binary_sem_clear(sem->S2);
    1114:	8b 43 04             	mov    0x4(%ebx),%eax
    1117:	89 04 24             	mov    %eax,(%esp)
    111a:	e8 a9 fb ff ff       	call   cc8 <binary_sem_clear>
	free(sem);
    111f:	89 5d 08             	mov    %ebx,0x8(%ebp)
}
    1122:	83 c4 14             	add    $0x14,%esp
    1125:	5b                   	pop    %ebx
    1126:	5d                   	pop    %ebp

void sem_clear(struct semaphore* sem )
{
	binary_sem_clear(sem->S1);
	binary_sem_clear(sem->S2);
	free(sem);
    1127:	e9 64 fe ff ff       	jmp    f90 <free>
    112c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi

00001130 <sem_downs>:
	}
	binary_sem_up(sem->S1);
}

void sem_downs(struct semaphore* sem, int num )
{
    1130:	55                   	push   %ebp
    1131:	89 e5                	mov    %esp,%ebp
    1133:	83 ec 18             	sub    $0x18,%esp
    1136:	89 5d f8             	mov    %ebx,-0x8(%ebp)
    1139:	8b 5d 08             	mov    0x8(%ebp),%ebx
    113c:	89 75 fc             	mov    %esi,-0x4(%ebp)
    113f:	8b 75 0c             	mov    0xc(%ebp),%esi
	binary_sem_down(sem->S2);
    1142:	8b 43 04             	mov    0x4(%ebx),%eax
    1145:	89 04 24             	mov    %eax,(%esp)
    1148:	e8 6b fb ff ff       	call   cb8 <binary_sem_down>
	binary_sem_down(sem->S1);
    114d:	8b 03                	mov    (%ebx),%eax
    114f:	89 04 24             	mov    %eax,(%esp)
    1152:	e8 61 fb ff ff       	call   cb8 <binary_sem_down>
	sem->value -= num;
    1157:	8b 43 08             	mov    0x8(%ebx),%eax
    115a:	29 f0                	sub    %esi,%eax
	if(sem->value > 0) {
    115c:	85 c0                	test   %eax,%eax

void sem_downs(struct semaphore* sem, int num )
{
	binary_sem_down(sem->S2);
	binary_sem_down(sem->S1);
	sem->value -= num;
    115e:	89 43 08             	mov    %eax,0x8(%ebx)
	if(sem->value > 0) {
    1161:	74 0b                	je     116e <sem_downs+0x3e>
		binary_sem_up(sem->S2);
    1163:	8b 43 04             	mov    0x4(%ebx),%eax
    1166:	89 04 24             	mov    %eax,(%esp)
    1169:	e8 52 fb ff ff       	call   cc0 <binary_sem_up>
	}
	binary_sem_up(sem->S1);
    116e:	8b 03                	mov    (%ebx),%eax
}
    1170:	8b 75 fc             	mov    -0x4(%ebp),%esi
    1173:	8b 5d f8             	mov    -0x8(%ebp),%ebx
	binary_sem_down(sem->S1);
	sem->value -= num;
	if(sem->value > 0) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    1176:	89 45 08             	mov    %eax,0x8(%ebp)
}
    1179:	89 ec                	mov    %ebp,%esp
    117b:	5d                   	pop    %ebp
	binary_sem_down(sem->S1);
	sem->value -= num;
	if(sem->value > 0) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    117c:	e9 3f fb ff ff       	jmp    cc0 <binary_sem_up>
    1181:	eb 0d                	jmp    1190 <sem_down>
    1183:	90                   	nop
    1184:	90                   	nop
    1185:	90                   	nop
    1186:	90                   	nop
    1187:	90                   	nop
    1188:	90                   	nop
    1189:	90                   	nop
    118a:	90                   	nop
    118b:	90                   	nop
    118c:	90                   	nop
    118d:	90                   	nop
    118e:	90                   	nop
    118f:	90                   	nop

00001190 <sem_down>:
	}
	binary_sem_up(sem->S1);
}

void sem_down(struct semaphore* sem )
{
    1190:	55                   	push   %ebp
    1191:	89 e5                	mov    %esp,%ebp
    1193:	53                   	push   %ebx
    1194:	83 ec 14             	sub    $0x14,%esp
    1197:	8b 5d 08             	mov    0x8(%ebp),%ebx
	binary_sem_down(sem->S2);
    119a:	8b 43 04             	mov    0x4(%ebx),%eax
    119d:	89 04 24             	mov    %eax,(%esp)
    11a0:	e8 13 fb ff ff       	call   cb8 <binary_sem_down>
	binary_sem_down(sem->S1);
    11a5:	8b 03                	mov    (%ebx),%eax
    11a7:	89 04 24             	mov    %eax,(%esp)
    11aa:	e8 09 fb ff ff       	call   cb8 <binary_sem_down>
	sem->value--;
    11af:	8b 43 08             	mov    0x8(%ebx),%eax
    11b2:	83 e8 01             	sub    $0x1,%eax
	if(sem->value > 0) {
    11b5:	85 c0                	test   %eax,%eax

void sem_down(struct semaphore* sem )
{
	binary_sem_down(sem->S2);
	binary_sem_down(sem->S1);
	sem->value--;
    11b7:	89 43 08             	mov    %eax,0x8(%ebx)
	if(sem->value > 0) {
    11ba:	74 0b                	je     11c7 <sem_down+0x37>
		binary_sem_up(sem->S2);
    11bc:	8b 43 04             	mov    0x4(%ebx),%eax
    11bf:	89 04 24             	mov    %eax,(%esp)
    11c2:	e8 f9 fa ff ff       	call   cc0 <binary_sem_up>
	}
	binary_sem_up(sem->S1);
    11c7:	8b 03                	mov    (%ebx),%eax
    11c9:	89 45 08             	mov    %eax,0x8(%ebp)
}
    11cc:	83 c4 14             	add    $0x14,%esp
    11cf:	5b                   	pop    %ebx
    11d0:	5d                   	pop    %ebp
	binary_sem_down(sem->S1);
	sem->value--;
	if(sem->value > 0) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    11d1:	e9 ea fa ff ff       	jmp    cc0 <binary_sem_up>
    11d6:	8d 76 00             	lea    0x0(%esi),%esi
    11d9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000011e0 <sem_ups>:
	}
	binary_sem_up(sem->S1);
}

void sem_ups(struct semaphore* sem, int num )
{
    11e0:	55                   	push   %ebp
    11e1:	89 e5                	mov    %esp,%ebp
    11e3:	83 ec 18             	sub    $0x18,%esp
    11e6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
    11e9:	8b 5d 08             	mov    0x8(%ebp),%ebx
    11ec:	89 75 fc             	mov    %esi,-0x4(%ebp)
    11ef:	8b 75 0c             	mov    0xc(%ebp),%esi
	binary_sem_down(sem->S1);
    11f2:	8b 03                	mov    (%ebx),%eax
    11f4:	89 04 24             	mov    %eax,(%esp)
    11f7:	e8 bc fa ff ff       	call   cb8 <binary_sem_down>
	sem->value+= num;
    11fc:	03 73 08             	add    0x8(%ebx),%esi
	if(sem->value == 1) {
    11ff:	83 fe 01             	cmp    $0x1,%esi
}

void sem_ups(struct semaphore* sem, int num )
{
	binary_sem_down(sem->S1);
	sem->value+= num;
    1202:	89 73 08             	mov    %esi,0x8(%ebx)
	if(sem->value == 1) {
    1205:	74 19                	je     1220 <sem_ups+0x40>
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    1207:	8b 03                	mov    (%ebx),%eax
}
    1209:	8b 75 fc             	mov    -0x4(%ebp),%esi
    120c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
	binary_sem_down(sem->S1);
	sem->value+= num;
	if(sem->value == 1) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    120f:	89 45 08             	mov    %eax,0x8(%ebp)
}
    1212:	89 ec                	mov    %ebp,%esp
    1214:	5d                   	pop    %ebp
	binary_sem_down(sem->S1);
	sem->value+= num;
	if(sem->value == 1) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    1215:	e9 a6 fa ff ff       	jmp    cc0 <binary_sem_up>
    121a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
void sem_ups(struct semaphore* sem, int num )
{
	binary_sem_down(sem->S1);
	sem->value+= num;
	if(sem->value == 1) {
		binary_sem_up(sem->S2);
    1220:	8b 43 04             	mov    0x4(%ebx),%eax
    1223:	89 04 24             	mov    %eax,(%esp)
    1226:	e8 95 fa ff ff       	call   cc0 <binary_sem_up>
    122b:	eb da                	jmp    1207 <sem_ups+0x27>
    122d:	8d 76 00             	lea    0x0(%esi),%esi

00001230 <sem_up>:
	}
	return ret;
}

void sem_up(struct semaphore* sem )
{
    1230:	55                   	push   %ebp
    1231:	89 e5                	mov    %esp,%ebp
    1233:	53                   	push   %ebx
    1234:	83 ec 14             	sub    $0x14,%esp
    1237:	8b 5d 08             	mov    0x8(%ebp),%ebx
	binary_sem_down(sem->S1);
    123a:	8b 03                	mov    (%ebx),%eax
    123c:	89 04 24             	mov    %eax,(%esp)
    123f:	e8 74 fa ff ff       	call   cb8 <binary_sem_down>
	sem->value++;
    1244:	8b 43 08             	mov    0x8(%ebx),%eax
    1247:	83 c0 01             	add    $0x1,%eax
	if(sem->value == 1) {
    124a:	83 f8 01             	cmp    $0x1,%eax
}

void sem_up(struct semaphore* sem )
{
	binary_sem_down(sem->S1);
	sem->value++;
    124d:	89 43 08             	mov    %eax,0x8(%ebx)
	if(sem->value == 1) {
    1250:	74 16                	je     1268 <sem_up+0x38>
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    1252:	8b 03                	mov    (%ebx),%eax
    1254:	89 45 08             	mov    %eax,0x8(%ebp)
}
    1257:	83 c4 14             	add    $0x14,%esp
    125a:	5b                   	pop    %ebx
    125b:	5d                   	pop    %ebp
	binary_sem_down(sem->S1);
	sem->value++;
	if(sem->value == 1) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    125c:	e9 5f fa ff ff       	jmp    cc0 <binary_sem_up>
    1261:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
void sem_up(struct semaphore* sem )
{
	binary_sem_down(sem->S1);
	sem->value++;
	if(sem->value == 1) {
		binary_sem_up(sem->S2);
    1268:	8b 43 04             	mov    0x4(%ebx),%eax
    126b:	89 04 24             	mov    %eax,(%esp)
    126e:	e8 4d fa ff ff       	call   cc0 <binary_sem_up>
	}
	binary_sem_up(sem->S1);
    1273:	8b 03                	mov    (%ebx),%eax
    1275:	89 45 08             	mov    %eax,0x8(%ebp)
}
    1278:	83 c4 14             	add    $0x14,%esp
    127b:	5b                   	pop    %ebx
    127c:	5d                   	pop    %ebp
	binary_sem_down(sem->S1);
	sem->value++;
	if(sem->value == 1) {
		binary_sem_up(sem->S2);
	}
	binary_sem_up(sem->S1);
    127d:	e9 3e fa ff ff       	jmp    cc0 <binary_sem_up>
    1282:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
    1289:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

00001290 <semaphore_create>:
#include "stat.h"
#include "user.h"
#include "semaphore.h"

struct semaphore* semaphore_create(int initial_semaphore_value)
{
    1290:	55                   	push   %ebp
    1291:	89 e5                	mov    %esp,%ebp
    1293:	83 ec 28             	sub    $0x28,%esp
	struct semaphore* ret;
	ret = malloc(sizeof(*ret));
    1296:	c7 04 24 0c 00 00 00 	movl   $0xc,(%esp)
#include "stat.h"
#include "user.h"
#include "semaphore.h"

struct semaphore* semaphore_create(int initial_semaphore_value)
{
    129d:	89 5d f4             	mov    %ebx,-0xc(%ebp)
    12a0:	89 75 f8             	mov    %esi,-0x8(%ebp)
    12a3:	89 7d fc             	mov    %edi,-0x4(%ebp)
    12a6:	8b 7d 08             	mov    0x8(%ebp),%edi
	struct semaphore* ret;
	ret = malloc(sizeof(*ret));
    12a9:	e8 72 fd ff ff       	call   1020 <malloc>
	ret->value = initial_semaphore_value;
    12ae:	89 78 08             	mov    %edi,0x8(%eax)
#include "semaphore.h"

struct semaphore* semaphore_create(int initial_semaphore_value)
{
	struct semaphore* ret;
	ret = malloc(sizeof(*ret));
    12b1:	89 c3                	mov    %eax,%ebx
	ret->value = initial_semaphore_value;
	if(((ret->S1 = binary_sem_create()) + (ret->S2 = binary_sem_create())) < 0) {
    12b3:	e8 f8 f9 ff ff       	call   cb0 <binary_sem_create>
    12b8:	89 03                	mov    %eax,(%ebx)
    12ba:	89 c6                	mov    %eax,%esi
    12bc:	e8 ef f9 ff ff       	call   cb0 <binary_sem_create>
    12c1:	01 c6                	add    %eax,%esi
    12c3:	89 43 04             	mov    %eax,0x4(%ebx)
    12c6:	78 20                	js     12e8 <semaphore_create+0x58>
		printf(2,"couldnt create the 2 binary semaphores");
		return 0;
	}
	if(initial_semaphore_value == 0) {
    12c8:	85 ff                	test   %edi,%edi
    12ca:	75 08                	jne    12d4 <semaphore_create+0x44>
		binary_sem_down(ret->S2);
    12cc:	89 04 24             	mov    %eax,(%esp)
    12cf:	e8 e4 f9 ff ff       	call   cb8 <binary_sem_down>
	}
	return ret;
}
    12d4:	89 d8                	mov    %ebx,%eax
    12d6:	8b 75 f8             	mov    -0x8(%ebp),%esi
    12d9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
    12dc:	8b 7d fc             	mov    -0x4(%ebp),%edi
    12df:	89 ec                	mov    %ebp,%esp
    12e1:	5d                   	pop    %ebp
    12e2:	c3                   	ret    
    12e3:	90                   	nop
    12e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
{
	struct semaphore* ret;
	ret = malloc(sizeof(*ret));
	ret->value = initial_semaphore_value;
	if(((ret->S1 = binary_sem_create()) + (ret->S2 = binary_sem_create())) < 0) {
		printf(2,"couldnt create the 2 binary semaphores");
    12e8:	c7 44 24 04 b0 16 00 	movl   $0x16b0,0x4(%esp)
    12ef:	00 
    12f0:	31 db                	xor    %ebx,%ebx
    12f2:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
    12f9:	e8 82 fa ff ff       	call   d80 <printf>
		return 0;
    12fe:	eb d4                	jmp    12d4 <semaphore_create+0x44>

00001300 <semaphore_release_atomic>:
	}
	sem_up(bb->full);
}

void semaphore_release_atomic(struct BB* bb)
{
    1300:	55                   	push   %ebp
    1301:	89 e5                	mov    %esp,%ebp
    1303:	83 ec 08             	sub    $0x8,%esp
	binary_sem_up(bb->mutex);
    1306:	8b 45 08             	mov    0x8(%ebp),%eax
    1309:	8b 00                	mov    (%eax),%eax
    130b:	89 45 08             	mov    %eax,0x8(%ebp)
}
    130e:	c9                   	leave  
	sem_up(bb->full);
}

void semaphore_release_atomic(struct BB* bb)
{
	binary_sem_up(bb->mutex);
    130f:	e9 ac f9 ff ff       	jmp    cc0 <binary_sem_up>
    1314:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
    131a:	8d bf 00 00 00 00    	lea    0x0(%edi),%edi

00001320 <semaphore_pop>:
}

void* semaphore_pop(struct BB* bb)
{
    1320:	55                   	push   %ebp
    1321:	89 e5                	mov    %esp,%ebp
    1323:	56                   	push   %esi
    1324:	53                   	push   %ebx
    1325:	83 ec 10             	sub    $0x10,%esp
    1328:	8b 5d 08             	mov    0x8(%ebp),%ebx
	void* element = 0;
	sem_down(bb->full);
    132b:	8b 43 08             	mov    0x8(%ebx),%eax
    132e:	89 04 24             	mov    %eax,(%esp)
    1331:	e8 5a fe ff ff       	call   1190 <sem_down>
	binary_sem_down(bb->mutex);
    1336:	8b 03                	mov    (%ebx),%eax
    1338:	89 04 24             	mov    %eax,(%esp)
    133b:	e8 78 f9 ff ff       	call   cb8 <binary_sem_down>
	if(bb->buffer[bb->consume] == 0) {
    1340:	8b 43 14             	mov    0x14(%ebx),%eax
    1343:	c1 e0 02             	shl    $0x2,%eax
    1346:	03 43 0c             	add    0xc(%ebx),%eax
    1349:	8b 30                	mov    (%eax),%esi
    134b:	85 f6                	test   %esi,%esi
    134d:	74 42                	je     1391 <semaphore_pop+0x71>
		printf(2,"something went wrong! buffer is empty and we are trying to consume\n");
	}
	else {
		element = bb->buffer[bb->consume];
		bb->buffer[bb->consume] = 0;
    134f:	c7 00 00 00 00 00    	movl   $0x0,(%eax)
		if(bb->consume == (bb->capacity - 1)) {
    1355:	8b 53 18             	mov    0x18(%ebx),%edx
    1358:	8b 43 14             	mov    0x14(%ebx),%eax
    135b:	83 ea 01             	sub    $0x1,%edx
    135e:	39 d0                	cmp    %edx,%eax
    1360:	74 26                	je     1388 <semaphore_pop+0x68>
			bb->consume = 0;
		}
		else {
			bb->consume++;
    1362:	83 c0 01             	add    $0x1,%eax
    1365:	89 43 14             	mov    %eax,0x14(%ebx)
		}
	}
	binary_sem_up(bb->mutex);
    1368:	8b 03                	mov    (%ebx),%eax
    136a:	89 04 24             	mov    %eax,(%esp)
    136d:	e8 4e f9 ff ff       	call   cc0 <binary_sem_up>
	sem_up(bb->empty);
    1372:	8b 43 04             	mov    0x4(%ebx),%eax
    1375:	89 04 24             	mov    %eax,(%esp)
    1378:	e8 b3 fe ff ff       	call   1230 <sem_up>
	return element;
}
    137d:	83 c4 10             	add    $0x10,%esp
    1380:	89 f0                	mov    %esi,%eax
    1382:	5b                   	pop    %ebx
    1383:	5e                   	pop    %esi
    1384:	5d                   	pop    %ebp
    1385:	c3                   	ret    
    1386:	66 90                	xchg   %ax,%ax
	}
	else {
		element = bb->buffer[bb->consume];
		bb->buffer[bb->consume] = 0;
		if(bb->consume == (bb->capacity - 1)) {
			bb->consume = 0;
    1388:	c7 43 14 00 00 00 00 	movl   $0x0,0x14(%ebx)
    138f:	eb d7                	jmp    1368 <semaphore_pop+0x48>
{
	void* element = 0;
	sem_down(bb->full);
	binary_sem_down(bb->mutex);
	if(bb->buffer[bb->consume] == 0) {
		printf(2,"something went wrong! buffer is empty and we are trying to consume\n");
    1391:	c7 44 24 04 d8 16 00 	movl   $0x16d8,0x4(%esp)
    1398:	00 
    1399:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
    13a0:	e8 db f9 ff ff       	call   d80 <printf>
    13a5:	eb c1                	jmp    1368 <semaphore_pop+0x48>
    13a7:	89 f6                	mov    %esi,%esi
    13a9:	8d bc 27 00 00 00 00 	lea    0x0(%edi,%eiz,1),%edi

000013b0 <semaphore_put_atomic>:
	binary_sem_up(bb->mutex);
	sem_up(bb->full);
}

void semaphore_put_atomic(struct BB* bb, void* element)
{
    13b0:	55                   	push   %ebp
    13b1:	89 e5                	mov    %esp,%ebp
    13b3:	56                   	push   %esi
    13b4:	53                   	push   %ebx
    13b5:	83 ec 10             	sub    $0x10,%esp
    13b8:	8b 5d 08             	mov    0x8(%ebp),%ebx
    13bb:	8b 75 0c             	mov    0xc(%ebp),%esi
	sem_down(bb->empty);
    13be:	8b 43 04             	mov    0x4(%ebx),%eax
    13c1:	89 04 24             	mov    %eax,(%esp)
    13c4:	e8 c7 fd ff ff       	call   1190 <sem_down>
	binary_sem_down(bb->mutex);
    13c9:	8b 03                	mov    (%ebx),%eax
    13cb:	89 04 24             	mov    %eax,(%esp)
    13ce:	e8 e5 f8 ff ff       	call   cb8 <binary_sem_down>
	if(bb->buffer[bb->produce] != 0) {
    13d3:	8b 43 10             	mov    0x10(%ebx),%eax
    13d6:	c1 e0 02             	shl    $0x2,%eax
    13d9:	03 43 0c             	add    0xc(%ebx),%eax
    13dc:	8b 10                	mov    (%eax),%edx
    13de:	85 d2                	test   %edx,%edx
    13e0:	74 26                	je     1408 <semaphore_put_atomic+0x58>
		printf(2,"something went wrong! buffer is full and we are trying to produce\n");
    13e2:	c7 44 24 04 1c 17 00 	movl   $0x171c,0x4(%esp)
    13e9:	00 
    13ea:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
    13f1:	e8 8a f9 ff ff       	call   d80 <printf>
		}
		else {
			bb->produce++;
		}
	}
	sem_up(bb->full);
    13f6:	8b 43 08             	mov    0x8(%ebx),%eax
    13f9:	89 45 08             	mov    %eax,0x8(%ebp)
}
    13fc:	83 c4 10             	add    $0x10,%esp
    13ff:	5b                   	pop    %ebx
    1400:	5e                   	pop    %esi
    1401:	5d                   	pop    %ebp
		}
		else {
			bb->produce++;
		}
	}
	sem_up(bb->full);
    1402:	e9 29 fe ff ff       	jmp    1230 <sem_up>
    1407:	90                   	nop
	binary_sem_down(bb->mutex);
	if(bb->buffer[bb->produce] != 0) {
		printf(2,"something went wrong! buffer is full and we are trying to produce\n");
	}
	else {
		bb->buffer[bb->produce] = element;
    1408:	89 30                	mov    %esi,(%eax)
		if(bb->produce == (bb->capacity - 1)) {
    140a:	8b 53 18             	mov    0x18(%ebx),%edx
    140d:	8b 43 10             	mov    0x10(%ebx),%eax
    1410:	83 ea 01             	sub    $0x1,%edx
    1413:	39 d0                	cmp    %edx,%eax
    1415:	74 09                	je     1420 <semaphore_put_atomic+0x70>
			bb->produce = 0;
		}
		else {
			bb->produce++;
    1417:	83 c0 01             	add    $0x1,%eax
    141a:	89 43 10             	mov    %eax,0x10(%ebx)
    141d:	eb d7                	jmp    13f6 <semaphore_put_atomic+0x46>
    141f:	90                   	nop
		printf(2,"something went wrong! buffer is full and we are trying to produce\n");
	}
	else {
		bb->buffer[bb->produce] = element;
		if(bb->produce == (bb->capacity - 1)) {
			bb->produce = 0;
    1420:	c7 43 10 00 00 00 00 	movl   $0x0,0x10(%ebx)
    1427:	eb cd                	jmp    13f6 <semaphore_put_atomic+0x46>
    1429:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

00001430 <semaphore_put>:
	ret->capacity = max_capacity;
	return ret;
}

void semaphore_put(struct BB* bb, void* element)
{
    1430:	55                   	push   %ebp
    1431:	89 e5                	mov    %esp,%ebp
    1433:	56                   	push   %esi
    1434:	53                   	push   %ebx
    1435:	83 ec 10             	sub    $0x10,%esp
    1438:	8b 5d 08             	mov    0x8(%ebp),%ebx
    143b:	8b 75 0c             	mov    0xc(%ebp),%esi
	sem_down(bb->empty);
    143e:	8b 43 04             	mov    0x4(%ebx),%eax
    1441:	89 04 24             	mov    %eax,(%esp)
    1444:	e8 47 fd ff ff       	call   1190 <sem_down>
	binary_sem_down(bb->mutex);
    1449:	8b 03                	mov    (%ebx),%eax
    144b:	89 04 24             	mov    %eax,(%esp)
    144e:	e8 65 f8 ff ff       	call   cb8 <binary_sem_down>
	if(bb->buffer[bb->produce] != 0) {
    1453:	8b 43 10             	mov    0x10(%ebx),%eax
    1456:	c1 e0 02             	shl    $0x2,%eax
    1459:	03 43 0c             	add    0xc(%ebx),%eax
    145c:	8b 08                	mov    (%eax),%ecx
    145e:	85 c9                	test   %ecx,%ecx
    1460:	74 36                	je     1498 <semaphore_put+0x68>
		printf(2,"something went wrong! buffer is full and we are trying to produce\n");
    1462:	c7 44 24 04 1c 17 00 	movl   $0x171c,0x4(%esp)
    1469:	00 
    146a:	c7 04 24 02 00 00 00 	movl   $0x2,(%esp)
    1471:	e8 0a f9 ff ff       	call   d80 <printf>
		}
		else {
			bb->produce++;
		}
	}
	binary_sem_up(bb->mutex);
    1476:	8b 03                	mov    (%ebx),%eax
    1478:	89 04 24             	mov    %eax,(%esp)
    147b:	e8 40 f8 ff ff       	call   cc0 <binary_sem_up>
	sem_up(bb->full);
    1480:	8b 43 08             	mov    0x8(%ebx),%eax
    1483:	89 45 08             	mov    %eax,0x8(%ebp)
}
    1486:	83 c4 10             	add    $0x10,%esp
    1489:	5b                   	pop    %ebx
    148a:	5e                   	pop    %esi
    148b:	5d                   	pop    %ebp
		else {
			bb->produce++;
		}
	}
	binary_sem_up(bb->mutex);
	sem_up(bb->full);
    148c:	e9 9f fd ff ff       	jmp    1230 <sem_up>
    1491:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
	binary_sem_down(bb->mutex);
	if(bb->buffer[bb->produce] != 0) {
		printf(2,"something went wrong! buffer is full and we are trying to produce\n");
	}
	else {
		bb->buffer[bb->produce] = element;
    1498:	89 30                	mov    %esi,(%eax)
		if(bb->produce == (bb->capacity - 1)) {
    149a:	8b 53 18             	mov    0x18(%ebx),%edx
    149d:	8b 43 10             	mov    0x10(%ebx),%eax
    14a0:	83 ea 01             	sub    $0x1,%edx
    14a3:	39 d0                	cmp    %edx,%eax
    14a5:	74 09                	je     14b0 <semaphore_put+0x80>
			bb->produce = 0;
		}
		else {
			bb->produce++;
    14a7:	83 c0 01             	add    $0x1,%eax
    14aa:	89 43 10             	mov    %eax,0x10(%ebx)
    14ad:	eb c7                	jmp    1476 <semaphore_put+0x46>
    14af:	90                   	nop
		printf(2,"something went wrong! buffer is full and we are trying to produce\n");
	}
	else {
		bb->buffer[bb->produce] = element;
		if(bb->produce == (bb->capacity - 1)) {
			bb->produce = 0;
    14b0:	c7 43 10 00 00 00 00 	movl   $0x0,0x10(%ebx)
    14b7:	eb bd                	jmp    1476 <semaphore_put+0x46>
    14b9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi

000014c0 <BB_create>:
#include "user.h"
#include "semaphore.h"
#include "boundedbuffer.h"

struct BB* BB_create(int max_capacity)
{
    14c0:	55                   	push   %ebp
    14c1:	89 e5                	mov    %esp,%ebp
    14c3:	83 ec 18             	sub    $0x18,%esp
    14c6:	89 75 fc             	mov    %esi,-0x4(%ebp)
    14c9:	8b 75 08             	mov    0x8(%ebp),%esi
    14cc:	89 5d f8             	mov    %ebx,-0x8(%ebp)
	struct BB* ret;
	if(max_capacity < 0)
    14cf:	85 f6                	test   %esi,%esi
    14d1:	79 15                	jns    14e8 <BB_create+0x28>
		return 0;
	ret->mutex = binary_sem_create();
	ret->produce = 0;
	ret->consume = 0;
	ret->capacity = max_capacity;
	return ret;
    14d3:	31 db                	xor    %ebx,%ebx
}
    14d5:	89 d8                	mov    %ebx,%eax
    14d7:	8b 75 fc             	mov    -0x4(%ebp),%esi
    14da:	8b 5d f8             	mov    -0x8(%ebp),%ebx
    14dd:	89 ec                	mov    %ebp,%esp
    14df:	5d                   	pop    %ebp
    14e0:	c3                   	ret    
    14e1:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
struct BB* BB_create(int max_capacity)
{
	struct BB* ret;
	if(max_capacity < 0)
		return 0;
	if((ret = malloc(sizeof(*ret))) <=0)
    14e8:	c7 04 24 1c 00 00 00 	movl   $0x1c,(%esp)
    14ef:	e8 2c fb ff ff       	call   1020 <malloc>
    14f4:	85 c0                	test   %eax,%eax
    14f6:	89 c3                	mov    %eax,%ebx
    14f8:	74 db                	je     14d5 <BB_create+0x15>
		return 0;
	if((ret->buffer = malloc(sizeof(void*) * max_capacity)) <=0)
    14fa:	8d 04 b5 00 00 00 00 	lea    0x0(,%esi,4),%eax
    1501:	89 04 24             	mov    %eax,(%esp)
    1504:	e8 17 fb ff ff       	call   1020 <malloc>
    1509:	85 c0                	test   %eax,%eax
    150b:	89 43 0c             	mov    %eax,0xc(%ebx)
    150e:	74 c3                	je     14d3 <BB_create+0x13>
		return 0;
	if((ret->empty = semaphore_create(max_capacity)) <=0)
    1510:	89 34 24             	mov    %esi,(%esp)
    1513:	e8 78 fd ff ff       	call   1290 <semaphore_create>
    1518:	85 c0                	test   %eax,%eax
    151a:	89 43 04             	mov    %eax,0x4(%ebx)
    151d:	74 b4                	je     14d3 <BB_create+0x13>
		return 0;
	if((ret->full = semaphore_create(0)) <=0)
    151f:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
    1526:	e8 65 fd ff ff       	call   1290 <semaphore_create>
    152b:	85 c0                	test   %eax,%eax
    152d:	89 43 08             	mov    %eax,0x8(%ebx)
    1530:	74 a1                	je     14d3 <BB_create+0x13>
		return 0;
	ret->mutex = binary_sem_create();
    1532:	e8 79 f7 ff ff       	call   cb0 <binary_sem_create>
	ret->produce = 0;
    1537:	c7 43 10 00 00 00 00 	movl   $0x0,0x10(%ebx)
	ret->consume = 0;
    153e:	c7 43 14 00 00 00 00 	movl   $0x0,0x14(%ebx)
	ret->capacity = max_capacity;
    1545:	89 73 18             	mov    %esi,0x18(%ebx)
		return 0;
	if((ret->empty = semaphore_create(max_capacity)) <=0)
		return 0;
	if((ret->full = semaphore_create(0)) <=0)
		return 0;
	ret->mutex = binary_sem_create();
    1548:	89 03                	mov    %eax,(%ebx)
	ret->produce = 0;
	ret->consume = 0;
	ret->capacity = max_capacity;
	return ret;
    154a:	eb 89                	jmp    14d5 <BB_create+0x15>
